2.17.2: 2011-06-17

net.sf.basedb.util.formatter
Class DateFormatter

java.lang.Object
  extended by net.sf.basedb.util.formatter.DateFormatter
All Implemented Interfaces:
Formatter<Date>

public class DateFormatter
extends Object
implements Formatter<Date>

Format a date for output in a client application. This implementation uses the SimpleDateFormat standard formatting routines.

Version:
2.0
Author:
nicklas
See Also:
SimpleDateFormat
Last modified
$Date: 2010-09-28 14:34:56 +0200 (Tue, 28 Sep 2010) $

Field Summary
private  DateFormat dateFormat
           
private  String format
           
 
Constructor Summary
DateFormatter(DateFormat dateFormat)
          Create a new date formatter.
DateFormatter(String format)
          Create a new date formatter.
 
Method Summary
 String format(Date value)
          Format a value by converting it to a string.
 DateFormat getDateFormat()
          Get access to the underlying DateFormat object used for formatting and parsing dates.
 Date parseString(String value)
          Parse a string and return a value of the correct type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dateFormat

private DateFormat dateFormat

format

private 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.

Specified by:
format in interface Formatter<Date>
Parameters:
value - The value to format
Returns:
A formatted 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 interface Formatter<Date>
Parameters:
value - The string to parse
Returns:
An object

getDateFormat

public DateFormat getDateFormat()
Get access to the underlying DateFormat object used for formatting and parsing dates.

Since:
2.8

2.17.2: 2011-06-17