Package net.sf.basedb.util.formatter
Class DateFormatter
- java.lang.Object
-
- net.sf.basedb.util.formatter.DateFormatter
-
- All Implemented Interfaces:
ExcelFormatter<Date,Date>
,Formatter<Date>
public class DateFormatter extends Object implements Formatter<Date>, ExcelFormatter<Date,Date>
Format a date for output in a client application. This implementation uses theSimpleDateFormat
standard formatting routines.- Version:
- 2.0
- Author:
- nicklas
- See Also:
SimpleDateFormat
- Last modified
- $Date: 2019-03-13 13:17:17 +0100 (ons, 13 mars 2019) $
-
-
Field Summary
Fields Modifier and Type Field Description private DateFormat
dateFormat
private String
format
-
Constructor Summary
Constructors Constructor Description DateFormatter(String format)
Create a new date formatter.DateFormatter(DateFormat dateFormat)
Create a new date formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(Date value)
Format a value by converting it to a string.DateFormat
getDateFormat()
Get access to the underlyingDateFormat
object used for formatting and parsing dates.Date
parseString(String value)
Parse a string and return a value of the correct type.ExcelValue<Date>
toExcelValue(Date value)
Convert and format the given value to an Excel value.
-
-
-
Field Detail
-
dateFormat
private final DateFormat dateFormat
-
format
private final String format
-
-
Constructor Detail
-
DateFormatter
public DateFormatter(DateFormat dateFormat)
Create a new date formatter.- Parameters:
dateFormat
- The date format to use when formatting
-
DateFormatter
public DateFormatter(String format)
Create a new date formatter.- Parameters:
format
- The date format to use when formatting- See Also:
SimpleDateFormat
-
-
Method Detail
-
format
public String format(Date value)
Description copied from interface:Formatter
Format a value by converting it to a string.
-
parseString
public Date parseString(String value)
Description copied from interface:Formatter
Parse a string and return a value of the correct type. A null input string should (unless otherwise documented by a specific formatter implementation) be allowed and may return null or any other "default" value.- Specified by:
parseString
in interfaceFormatter<Date>
- Parameters:
value
- The string to parse- Returns:
- An object
-
getDateFormat
public DateFormat getDateFormat()
Get access to the underlyingDateFormat
object used for formatting and parsing dates.- Since:
- 2.8
-
toExcelValue
public ExcelValue<Date> toExcelValue(Date value)
Description copied from interface:ExcelFormatter
Convert and format the given value to an Excel value. If the value is null the implementation may return null to create an empty cell or it may return another non-null value.- Specified by:
toExcelValue
in interfaceExcelFormatter<Date,Date>
- Since:
- 3.15
-
-