FileDocCategorySizeDatePackage
DateFormatSymbols.javaAPI DocphoneME MR2 API (J2ME)6287Wed May 02 18:00:46 BST 2007com.sun.j2me.global

DateFormatSymbols

public class DateFormatSymbols extends Object implements SerializableResource
DateFormatSymbols is class for encapsulating localizable date/time formatting data, such as the names of the months, the names of the days of the week, and the time zone data. DateTimeFormat uses DateFormatSymbols to encapsulate this information.

DateFormatSymbols is typicaly obtained from javax.microedition.ResourceManager respectively from DevResourceManager.getDateFormatSymbols() from resource file for given locale.

Typically you shouldn't use DateFormatSymbols directly. Rather, you are encouraged to create a date/time formatter with the DateTimeFormat class's factory methods: getInstance(int style, String locale) These methods automatically create a DateFormatSymbols for the formatter so that you don't have to. All fields are public intentionaly.

Fields Summary
public String[]
eras
eras.
public String[]
months
month names.
public String[]
shortMonths
short month names.
public String[]
weekDays
day in week names.
public String[]
shortWeekDays
short day in week names.
public String[]
ampms
ampms.
public String[]
patterns
localized patterns 6 possible styles as they are defined in {@link DateTimeFormat}.
public String
locale
locale of this symbols.
Constructors Summary
public DateFormatSymbols()
Create new DateFormatSymbol uninitialized.

 
Methods Summary
public java.lang.Objectclone()
The method clones the resource.

return
copy of the resource or null if clonning wasn't possible

        DateFormatSymbols newDfs = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            write(baos);
            baos.close();
            byte[] buffer = baos.toByteArray();
            ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
            newDfs = new DateFormatSymbols();
            newDfs.read(bais);
        } catch (IOException ioe) {
            // cannot clone resource
        }
        return newDfs;
    
public voidread(java.io.InputStream in)
Read DateFormatSymbols object from input stream.

param
in input stream
throws
java.io.IOException error reading resource
throws
javax.microedition.global.ResourceException error creating resource



                                    
         
                                                     
        DataInputStream dis = new DataInputStream(in);
        readStrings(eras, dis);
        readStrings(months, dis);
        readStrings(shortMonths, dis);
        readStrings(weekDays, dis);
        readStrings(shortWeekDays, dis);
        readStrings(ampms, dis);
        readStrings(patterns, dis);
        locale = dis.readUTF();
    
protected voidreadStrings(java.lang.String[] array, java.io.DataInputStream dis)
Read strings helper. Reads string array.

param
array string array to read to
param
dis input stream
throws
IOException exception when read failed

        for (int i = 0; i < array.length; i++) {
            array[i] = dis.readUTF();
        }
    
public voidwrite(java.io.OutputStream out)
Serialize DateFormatSymbols object into output stream.

param
out output stream
throws
java.io.IOException is thrown if write fails
throws
javax.microedition.global.ResourceException if resource can't be written

        DataOutputStream dous = new DataOutputStream(out);
        writeStrings(eras, dous);
        writeStrings(months, dous);
        writeStrings(shortMonths, dous);
        writeStrings(weekDays, dous);
        writeStrings(shortWeekDays, dous);
        writeStrings(ampms, dous);
        writeStrings(patterns, dous);
        dous.writeUTF(locale);
        dous.flush();
    
protected voidwriteStrings(java.lang.String[] array, java.io.DataOutputStream dous)
Write array helper. Writes string array.

param
array strings to write
param
dous output stream
throws
IOException exception when write failed

        for (int i = 0; i < array.length; i++) {
            dous.writeUTF(array[i]);
        }