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>
Format a date for output in a client application. This implementation
uses the
SimpleDateFormat
standard formatting routines.
NOTE! The SimpleDateFormat implementation is not thread-safe which may
have affected instances of this class before BASE 3.19.7. Since BASE 3.19.7
this class has implemented synchronization and should be thread-safe.
But beware of the getDateFormat()
which return the underlying
formatter instance that is not thread-safe!
- Version:
- 2.0
- Author:
- nicklas
- See Also:
- Last modified
- $Date: 2023-02-08 13:58:34 +0100 (Wed, 08 Feb 2023) $
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDateFormatter
(String format) Create a new date formatter.DateFormatter
(DateFormat dateFormat) Create a new date formatter. -
Method Summary
Modifier and TypeMethodDescriptionFormat a value by converting it to a string.Get access to the underlyingDateFormat
object used for formatting and parsing dates.parseString
(String value) Parse a string and return a value of the correct type.toExcelValue
(Date value) Convert and format the given value to an Excel value.
-
Field Details
-
dateFormat
-
format
-
-
Constructor Details
-
DateFormatter
Create a new date formatter.- Parameters:
dateFormat
- The date format to use when formatting
-
DateFormatter
Create a new date formatter.- Parameters:
format
- The date format to use when formatting- See Also:
-
-
Method Details
-
format
Description copied from interface:Formatter
Format a value by converting it to a string. -
parseString
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
Get access to the underlyingDateFormat
object used for formatting and parsing dates.- Since:
- 2.8
-
toExcelValue
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
-