| new MessageFormat ( pattern ) | ใช้สร้าง Object MessageFormat โดยมีการกำหนดรูปแบบของข้อความที่ต้องการจัดไว้ด้วย |
|---|---|
| new MessageFormat ( pattern, locale ) | ใช้สร้าง Object MessageFormat โดยมีการกำหนดรูปแบบของข้อความที่ต้องการจัดไว้ด้วย |
| applyPattern() | ใช้กำหนดรูปแบบของข้อความที่ต้องการจัด ให้กับ Object MessageFormat |
| setLocale() | ใช้กำหนด object Locale ให้กับ Object MessageFormat |
| getLocale() | ใช้คืนค่า object Locale ของ Object MessageFormat |
| format ( object_array ) | ใช้คืนค่า ข้อความ ที่ได้หลังจากการจัดรูปแบบแล้ว |
| format ( pattern, object_array ) | ใช้คืนค่า ข้อความ ที่ได้หลังจากการจัดรูปแบบแล้ว |
| โครงสร้างของ Pattern ของการจัดรูปแบบ | ได้แก่ { index }, { index, type_var }, { index, type_var, kind } |
| ชนิดข้อมูล และรูปแบบของข้อมูล ที่ใช้ในการจัดรูปแบบ | ได้แก่ time, date, number, choice |
method:new MessageFormat ( object_string_pattern );
return type:MessageFormat
content:ใช้สร้าง Object MessageFormat โดยมีการกำหนดรูปแบบของข้อความที่ต้องการจัดไว้ด้วย
example:String pattern = new String ( "{0}" ); MessageFormat message_format = new MessageFormat ( pattern );
method:new MessageFormat ( pattern, locale );
return type:MessageFormat
content:ใช้สร้าง Object MessageFormat โดยมีการกำหนดรูปแบบของข้อความที่ต้องการจัดไว้ด้วย
example:String pattern = new String ( "{0}" ); Locale locale = new Locale ( "th", "TH" ); MessageFormat message_format = new MessageFormat ( pattern, locale );
method:applyPattern ( pattern );
return type:void
content:ใช้กำหนดรูปแบบของข้อความที่ต้องการจัด ให้กับ Object MessageFormat
example:String pattern = new String ( "{0}" ); MessageFormat message_format = new MessageFormat (); message_format.applyPattern ( pattern );
method:setLocale ( object_locale );
return type:void
content:ใช้กำหนด object Locale ให้กับ Object MessageFormat
example:Locale locale = new Locale ( "th", "TH" ); MessageFormat message_format = new MessageFormat (); message_format.setLocale ( locale );
method:getLocale ();
return type:Locale
content:ใช้คืนค่า object Locale ของ Object MessageFormat
example:MessageFormat message_format = new MessageFormat (); Locale locale = message_format.getLocale ();
method:format ( object_array );
return type:String
content:ใช้คืนค่า ข้อความ ที่ได้หลังจากการจัดรูปแบบแล้ว
example:MessageFormat message_format = new MessageFormat ( "{1} explain about {0}." ); String [] str_data = { "JAVA-SWING", "E-Learning :: " }; String data_format = message_format.format ( str_data );
method:format ( pattern, object_array );
return type:String
special:static
content:ใช้คืนค่า ข้อความ ที่ได้หลังจากการจัดรูปแบบแล้ว
example:String [] str_data = { "JAVA-SWING", "E-Learning :: ", new Date () }; String pattern = new String ( "{1} explain about {0}. update-time {3, date, full}" ); String data_format = MessageFormat.format ( pattern, str_data );
subject:โครงสร้างของ Pattern ของการจัดรูปแบบ
content:โครงสร้างของ Pattern ของการจัดรูปแบบ ได้แก่ { index } เป็นการนำข้อความจากดัชนีที่กำหนดมาแสดง { index, type_var } เป็นการนำข้อความจากดัชนีที่กำหนดมาแสดง โดยแสดงเป็นชนิดข้อมูลที่กำหนด { index, type_var, kind } เป็นการนำข้อความจากดัชนีที่กำหนดมาแสดง โดยแสดงเป็นชนิดข้อมูลที่กำหนด ตามรูปแบบที่กำหนด
subject:ชนิดข้อมูล และรูปแบบของข้อมูล ที่ใช้ในการจัดรูปแบบ
content:ชนิดข้อมูล และรูปแบบของข้อมูล ที่ใช้ในการจัดรูปแบบ ได้แก่ - time มีรูปแบบ ดังนี้ short, medium, long, full, dateFormatPattern - date มีรูปแบบ ดังนี้ short, medium, long, full, dateFormatPattern - number มีรูปแบบ ดังนี้ currency, percent, integer, numberFormatPattern - choice มีรูปแบบ ดังนี้ choiceFormatPattern