|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ujac.util.text.FormatHelper
public class FormatHelper
Name: FormatHelper
Description: A helper class handling formatting objects.
Field Summary | |
---|---|
static String |
ATTRIBUTE_NAME
Constant for the format helper attribute name, needed to store the format helper in the session or request. |
protected DateFormat |
dateFormat
The date format. |
protected NumberFormat |
doubleFormat
The floating point format. |
protected NumberFormat |
integerFormat
The integer format. |
static String |
ISO_DATE_PATTERN
Constant for the ISO 8601 date format pattern. |
static String |
ISO_TIME_PATTERN
Constant for the ISO 8601 time format pattern. |
static String |
ISO_TIMESTAMP_PATTERN
Constant for the ISO 8601 timestamp format pattern. |
protected Locale |
locale
The locale. |
protected DateFormat |
timeFormat
The time format. |
protected DateFormat |
timestampFormat
The timestamp format. |
Constructor Summary | |
---|---|
FormatHelper()
Constructs a FormatHelper instance with no specific attributes. |
|
FormatHelper(Locale locale)
Constructs a FormatHelper instance with specific attributes. |
Method Summary | |
---|---|
Object |
clone()
|
DateFormat |
createDateFormat(String formatPattern)
Creates a date format for the current locale. |
static FormatHelper |
createInstance()
Creates an FormatHelper instance according to the registered prototype. |
static FormatHelper |
createInstance(Locale locale)
Creates an FormatHelper instance according to the registered prototype. |
static FormatHelper |
createIsoInstance()
Creates an FormatHelper instance according to the registered prototype. |
NumberFormat |
createNumberFormat(String formatPattern)
Creates a number format for the current locale. |
String |
formatDate(Date date)
Formats the given date as String using the current date format. |
String |
formatDouble(double value)
Formats the given double as String using the current double format. |
String |
formatFloat(float value)
Formats the given float as String using the current double format. |
String |
formatInt(int value)
Formats the given long as String using the current integer format. |
String |
formatLong(long value)
Formats the given long as String using the current integer format. |
String |
formatShort(short value)
Formats the given short as String using the current integer format. |
String |
formatTime(Date date)
Formats the given time as String using the current time format. |
String |
formatTimestamp(Date date)
Formats the given date as String using the current time format. |
DateFormat |
getDateFormat()
Gets the current date format. |
DateFormat |
getDefaultDateFormat(Locale locale)
Gets the default date format for the given locale. |
NumberFormat |
getDefaultDoubleFormat(Locale locale)
Gets the default double format for the given locale. |
NumberFormat |
getDefaultIntegerFormat(Locale locale)
Gets the default integer format for the given locale. |
DateFormat |
getDefaultTimeFormat(Locale locale)
Gets the default time format for the given locale. |
DateFormat |
getDefaultTimestampFormat(Locale locale)
Gets the default timestamp format for the given locale. |
NumberFormat |
getDoubleFormat()
Gets the current double format. |
FormatHelper |
getInstance(Locale locale)
Gets an instance of the FormatHelper for the given locale. |
NumberFormat |
getIntegerFormat()
Gets the current integer format. |
DateFormat |
getIsoDateFormat()
Gets the date format according to the ISO 8601. |
DateFormat |
getIsoTimeFormat()
Gets the time format according to the ISO 8601. |
DateFormat |
getIsoTimestampFormat()
Gets the timestamp format according to the ISO 8601. |
Locale |
getLocale()
Gets the used locale. |
DateFormat |
getTimeFormat()
Gets the current time format. |
DateFormat |
getTimestampFormat()
Gets the current timestamp format. |
Format |
lookupFormat(String formatString)
Looks up the macro definition for the given macro name. |
Date |
parseDate(String text)
Parses a date from the given text using the current date format. |
long |
parseDouble(String text)
Parses a double from the given text using the current double format. |
long |
parseFloat(String text)
Parses a float from the given text using the current double format. |
int |
parseInt(String text)
Parses an integer from the given text using the current integer format. |
long |
parseLong(String text)
Parses a long from the given text using the current integer format. |
short |
parseShort(String text)
Parses a short from the given text using the current integer format. |
Time |
parseTime(String text)
Parses a time from the given text using the current time format. |
Timestamp |
parseTimestamp(String text)
Parses a time stamp from the given text using the current timestamp format. |
protected void |
readData(ObjectInputStream s)
Reads the object's data from the given stream. |
void |
registerFormat(String formatString,
Format formatInstance)
Registers the given format instance for the also given format string. |
void |
setDateFormat(DateFormat dateFormat)
Sets the date format. |
DateFormat |
setDateFormat(String formatPattern)
Sets the date format. |
void |
setDoubleFormat(NumberFormat doubleFormat)
Sets the double format. |
NumberFormat |
setDoubleFormat(String formatPattern)
Sets the double format. |
void |
setIntegerFormat(NumberFormat integerFormat)
Sets the integer format. |
NumberFormat |
setIntegerFormat(String formatPattern)
Sets the integer format. |
static void |
setPrototype(FormatHelper prototype)
Defines the format helper prototype. |
void |
setTimeFormat(DateFormat timeFormat)
Sets the timeFormat. |
DateFormat |
setTimeFormat(String formatPattern)
Sets the time format. |
void |
setTimestampFormat(DateFormat timestampFormat)
Sets the timestampFormat. |
DateFormat |
setTimestampFormat(String formatPattern)
Sets the timestamp format. |
protected void |
writeData(ObjectOutputStream s)
Writes the object's data to the given stream. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ATTRIBUTE_NAME
public static final String ISO_DATE_PATTERN
public static final String ISO_TIME_PATTERN
public static final String ISO_TIMESTAMP_PATTERN
protected Locale locale
protected DateFormat dateFormat
protected DateFormat timeFormat
protected DateFormat timestampFormat
protected NumberFormat integerFormat
protected NumberFormat doubleFormat
Constructor Detail |
---|
public FormatHelper()
public FormatHelper(Locale locale)
locale
- The initial locale.Method Detail |
---|
public static FormatHelper createInstance()
public static FormatHelper createIsoInstance()
public static FormatHelper createInstance(Locale locale)
locale
- The locale to use.
public static void setPrototype(FormatHelper prototype)
prototype
- The prototype to define.public FormatHelper getInstance(Locale locale)
locale
- The locale to use.
public Locale getLocale()
public NumberFormat getIntegerFormat()
public void setIntegerFormat(NumberFormat integerFormat)
integerFormat
- The integerFormat to setpublic NumberFormat setIntegerFormat(String formatPattern)
formatPattern
- The format pattern to use.
public NumberFormat getDoubleFormat()
public void setDoubleFormat(NumberFormat doubleFormat)
doubleFormat
- The doubleFormat to setpublic NumberFormat setDoubleFormat(String formatPattern)
formatPattern
- The format pattern to use.
public DateFormat getDateFormat()
public void setDateFormat(DateFormat dateFormat)
dateFormat
- The date format to setpublic DateFormat setDateFormat(String formatPattern)
formatPattern
- The format pattern to use.
public DateFormat getTimeFormat()
public void setTimeFormat(DateFormat timeFormat)
timeFormat
- The timeFormat to setpublic DateFormat setTimeFormat(String formatPattern)
formatPattern
- The format pattern to use.
public DateFormat getTimestampFormat()
public void setTimestampFormat(DateFormat timestampFormat)
timestampFormat
- The timestampFormat to setpublic DateFormat setTimestampFormat(String formatPattern)
formatPattern
- The format pattern to use.
public NumberFormat createNumberFormat(String formatPattern)
formatPattern
- The format pattern to use.
public DateFormat createDateFormat(String formatPattern)
formatPattern
- The format pattern to use.
public NumberFormat getDefaultIntegerFormat(Locale locale)
locale
- The locale to use.
public NumberFormat getDefaultDoubleFormat(Locale locale)
locale
- The locale to use.
public DateFormat getDefaultDateFormat(Locale locale)
locale
- The locale to use.
public DateFormat getDefaultTimeFormat(Locale locale)
locale
- The locale to use.
public DateFormat getDefaultTimestampFormat(Locale locale)
locale
- The locale to use.
public DateFormat getIsoDateFormat()
public DateFormat getIsoTimeFormat()
public DateFormat getIsoTimestampFormat()
public void registerFormat(String formatString, Format formatInstance)
formatString
- The format string.formatInstance
- The format instance.public Format lookupFormat(String formatString)
formatString
- The format string.
public int parseInt(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the number parsing failed.getIntegerFormat()
public String formatInt(int value)
value
- The value to format.
getIntegerFormat()
public long parseLong(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the number parsing failed.getIntegerFormat()
public String formatLong(long value)
value
- The value to format.
getIntegerFormat()
public short parseShort(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the number parsing failed.getIntegerFormat()
public String formatShort(short value)
value
- The value to format.
getIntegerFormat()
public long parseDouble(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the number parsing failed.getDoubleFormat()
public String formatDouble(double value)
value
- The value to format.
getDoubleFormat()
public long parseFloat(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the number parsing failed.getDoubleFormat()
public String formatFloat(float value)
value
- The value to format.
getDoubleFormat()
public Date parseDate(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the date parsing failed.getDateFormat()
public String formatDate(Date date)
date
- The date to format.
public Time parseTime(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the time parsing failed.getTimeFormat()
public String formatTime(Date date)
date
- The date to format.
public Timestamp parseTimestamp(String text) throws ParseException
text
- The text to parse.
ParseException
- In case the time parsing failed.getTimestampFormat()
public String formatTimestamp(Date date)
date
- The date to format.
public Object clone()
clone
in class Object
Object.clone()
protected void writeData(ObjectOutputStream s) throws IOException
s
- The stream to write to
IOException
- In case the data output failed.protected void readData(ObjectInputStream s) throws IOException, ClassNotFoundException
s
- The stream to read from.
IOException
- In case the data reading failed.
ClassNotFoundException
- In case the class to deserialize could not be found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |