Package org.wicketstuff.datetime
Class StyleDateConverter
java.lang.Object
org.wicketstuff.datetime.DateConverter
org.wicketstuff.datetime.StyleDateConverter
- All Implemented Interfaces:
Serializable,IConverter<Date>,IClusterable
Date converter that uses Joda Time and can be configured to take the time zone difference between
clients and server into account, and that is configured for a certain date style. The pattern
will always be locale specific.
This converter is especially suited on a per-component base.
- Author:
- eelcohillenius
- See Also:
-
DateTextFieldDateTimeDateTimeFormatDateTimeZone- Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionStyleDateConverter(boolean applyTimeZoneDifference) Construct.StyleDateConverter(String dateStyle, boolean applyTimeZoneDifference) Construct. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetDatePattern(Locale locale) Gets the optional date pattern.protected org.joda.time.format.DateTimeFormatterMethods inherited from class org.wicketstuff.datetime.DateConverter
convertToObject, convertToString, getApplyTimeZoneDifference, getClientTimeZone, getTimeZone
-
Constructor Details
-
StyleDateConverter
public StyleDateConverter(boolean applyTimeZoneDifference) Construct. The dateStyle 'S-' (which is the same asDateTimeFormat.shortDate()) will be used for constructing the date format for the current locale. When applyTimeZoneDifference is true, the current time is applied on the parsed date, and the date will be corrected for the time zone difference between the server and the client. For instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9 hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while the client sees 12/24.- Parameters:
applyTimeZoneDifference- whether to apply the difference in time zones between client and server
-
StyleDateConverter
Construct. The provided pattern will be used as the base format (but they will be localized for the current locale) and if null,DateTimeFormat.shortDate()will be used. When applyTimeZoneDifference is true, the current time is applied on the parsed date, and the date will be corrected for the time zone difference between the server and the client. For instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9 hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while the client sees 12/24.- Parameters:
dateStyle- Date style to use. The first character is the date style, and the second character is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' for long, and 'F' for full. A date or time may be ommitted by specifying a style character '-'. SeeDateTimeFormat.forStyle(String).applyTimeZoneDifference- whether to apply the difference in time zones between client and server- Throws:
IllegalArgumentException- in case dateStyle is null
-
-
Method Details
-
getDatePattern
Gets the optional date pattern.- Specified by:
getDatePatternin classDateConverter- Parameters:
locale- The locale used to convert the value- Returns:
- datePattern
-
getFormat
- Specified by:
getFormatin classDateConverter- Parameters:
locale- The locale used to convert the value- Returns:
- formatter The formatter for the current conversion
-