Class DateBox.DefaultFormat
- java.lang.Object
-
- com.google.gwt.user.datepicker.client.DateBox.DefaultFormat
-
- All Implemented Interfaces:
DateBox.Format
- Enclosing class:
- DateBox
public static class DateBox.DefaultFormat extends java.lang.Object implements DateBox.Format
DefaultDateBox.Formatclass. The date is first parsed using theDateTimeFormatsupplied by the user, orDateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUMby default.If that fails, we then try to parse again using the default browser date parsing.
If that fails, thedateBoxFormatErrorcss style is applied to theDateBox. The style will be removed when either a successfulparse(DateBox,String, boolean)is called orformat(DateBox,Date)is called.Use a different
DateBox.Formatinstance to change that behavior.
-
-
Constructor Summary
Constructors Constructor Description DefaultFormat()Creates a new default format instance.DefaultFormat(DateTimeFormat dateTimeFormat)Creates a new default format instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(DateBox box, java.util.Date date)Formats the provided date.DateTimeFormatgetDateTimeFormat()Gets the date time format.java.util.Dateparse(DateBox dateBox, java.lang.String dateText, boolean reportError)Parses the provided string as a date.voidreset(DateBox dateBox, boolean abandon)If the format did any modifications to the date box's styling, reset them now.
-
-
-
Constructor Detail
-
DefaultFormat
public DefaultFormat()
Creates a new default format instance.
-
DefaultFormat
public DefaultFormat(DateTimeFormat dateTimeFormat)
Creates a new default format instance.- Parameters:
dateTimeFormat- theDateTimeFormatto use with thisDateBox.Format.
-
-
Method Detail
-
format
public java.lang.String format(DateBox box, java.util.Date date)
Description copied from interface:DateBox.FormatFormats the provided date. Note, a null date is a possible input.- Specified by:
formatin interfaceDateBox.Format- Parameters:
box- the date box you are formattingdate- the date to format- Returns:
- the formatted date as a string
-
getDateTimeFormat
public DateTimeFormat getDateTimeFormat()
Gets the date time format.- Returns:
- the date time format
-
parse
public java.util.Date parse(DateBox dateBox, java.lang.String dateText, boolean reportError)
Description copied from interface:DateBox.FormatParses the provided string as a date.- Specified by:
parsein interfaceDateBox.Format- Parameters:
dateBox- the date boxdateText- the string representing a datereportError- should the formatter indicate a parse error to the user?- Returns:
- the date created, or null if there was a parse error
-
reset
public void reset(DateBox dateBox, boolean abandon)
Description copied from interface:DateBox.FormatIf the format did any modifications to the date box's styling, reset them now.- Specified by:
resetin interfaceDateBox.Format- Parameters:
dateBox- the date boxabandon- true when the current format is being replaced by another
-
-