Interface DatePrinter
-
- All Superinterfaces:
org.apache.wicket.util.io.IClusterable
,Serializable
- All Known Subinterfaces:
DateTimePrinter
- All Known Implementing Classes:
DatePrinter.EmptyDatePrinter
,DatePrinter.JavaDatePrinter
,DateTimePrinter.EmptyDateTimePrinter
,DateTimePrinter.JavaDateTimePrinter
public interface DatePrinter extends org.apache.wicket.util.io.IClusterable
Utility for printing java date objects using the java.time classes. Takes care of setting the correct locale and timezone. Prints the date but excludes the time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DatePrinter.EmptyDatePrinter
static class
DatePrinter.JavaDatePrinter
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description DatePrinter
appendDST()
Append an explanatory string to the printed date if it is in Daylight Saving Time.static DatePrinter
of(Instant instant)
static DatePrinter
of(Calendar calendar)
static DatePrinter
of(Date date)
String
print()
Print with default style (medium-short).String
print(String pattern)
Print with specified pattern.String
print(FormatStyle style)
Print with specified FormatStyle.
-
-
-
Method Detail
-
print
String print()
Print with default style (medium-short).- Returns:
- the date as a string formatted in default style
-
print
String print(String pattern)
Print with specified pattern. See patterns for all pattern options.- Parameters:
pattern
- the pattern to use, not null- Returns:
- the date as a string based on the pattern
-
print
String print(FormatStyle style)
Print with specified FormatStyle. Check here for all possible styles.- Parameters:
style
- the formatter style to obtain, not null- Returns:
- the date as a string based on the style
-
appendDST
DatePrinter appendDST()
Append an explanatory string to the printed date if it is in Daylight Saving Time. Java shifts the time zone +1 if a date is in DST (e.g. CET becomes CEST), so to avoid confusion we add a description after the time zone (e.g. " (DST)" in English).- Returns:
- the DatePrinter instance
-
of
static DatePrinter of(Date date)
-
of
static DatePrinter of(Calendar calendar)
-
of
static DatePrinter of(Instant instant)
-
-