public static class DateBox.DefaultFormat extends Object implements DateBox.Format
DateBox.Format
class. The date is first parsed using the
DateTimeFormat
supplied by the user, or
DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM
by default.
If that fails, we then try to parse again using the default browser date parsing.
If that fails, thedateBoxFormatError
css style is applied to
the DateBox
. The style will be removed when either a successful
parse(DateBox,String, boolean)
is called or
format(DateBox,Date)
is called.
Use a different DateBox.Format
instance to change that behavior.
Constructor and Description |
---|
DefaultFormat()
Creates a new default format instance.
|
DefaultFormat(DateTimeFormat dateTimeFormat)
Creates a new default format instance.
|
Modifier and Type | Method and Description |
---|---|
String |
format(DateBox box,
Date date)
Formats the provided date.
|
DateTimeFormat |
getDateTimeFormat()
Gets the date time format.
|
Date |
parse(DateBox dateBox,
String dateText,
boolean reportError)
Parses the provided string as a date.
|
void |
reset(DateBox dateBox,
boolean abandon)
If the format did any modifications to the date box's styling, reset them
now.
|
public DefaultFormat()
public DefaultFormat(DateTimeFormat dateTimeFormat)
dateTimeFormat
- the DateTimeFormat
to use with this
DateBox.Format
.public String format(DateBox box, Date date)
DateBox.Format
format
in interface DateBox.Format
box
- the date box you are formattingdate
- the date to formatpublic DateTimeFormat getDateTimeFormat()
public Date parse(DateBox dateBox, String dateText, boolean reportError)
DateBox.Format
parse
in interface DateBox.Format
dateBox
- the date boxdateText
- the string representing a datereportError
- should the formatter indicate a parse error to the
user?public void reset(DateBox dateBox, boolean abandon)
DateBox.Format
reset
in interface DateBox.Format
dateBox
- the date boxabandon
- true when the current format is being replaced by anotherCopyright © 2018. All rights reserved.