org.rapla.components.util
Class SerializableDateTimeFormat

java.lang.Object
  extended by org.rapla.components.util.SerializableDateTimeFormat

public class SerializableDateTimeFormat
extends Object

Provides methods for parsing and formating dates and times in the following format:
2002-25-05 for dates and 13:00:00 for times. This is according to the xschema specification for dates and time. WARNING: Do not share instances of this class between threads. Its NOT thread safe


Constructor Summary
SerializableDateTimeFormat()
           
SerializableDateTimeFormat(Calendar calendar)
           
 
Method Summary
 String formatDate(Date date)
          same as formatDate(date, false).
 String formatDate(Date date, boolean adaptDay)
          returns the date object in the following format: 2001-10-21.
 String formatTime(Date date)
          returns the time object in the following format: 13:00:00.
 Date parseDate(String date, boolean fillDate)
          The date-string must be in the following format 2001-10-21.
 Date parseDateTime(String date, String time)
          The date-string must be in the following format 2001-10-21.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializableDateTimeFormat

public SerializableDateTimeFormat()

SerializableDateTimeFormat

public SerializableDateTimeFormat(Calendar calendar)
Method Detail

parseDateTime

public Date parseDateTime(String date,
                          String time)
                   throws ParseException
The date-string must be in the following format 2001-10-21. The format of the time-string is 18:00:00.

Returns:
The parsed date
Throws:
ParseException - when the date cannot be parsed.

parseDate

public Date parseDate(String date,
                      boolean fillDate)
               throws ParseException
The date-string must be in the following format 2001-10-21.

Parameters:
fillDate - if this flag is set the time will be 24:00 instead of 0:00 When this flag is set the time parameter should be null
Returns:
The parsed date
Throws:
ParseException - when the date cannot be parsed.

formatTime

public String formatTime(Date date)
returns the time object in the following format: 13:00:00.


formatDate

public String formatDate(Date date,
                         boolean adaptDay)
returns the date object in the following format: 2001-10-21.

Parameters:
adaptDay - if the flag is set 2001-10-21 will be stored as 2001-10-20. This is usefull for end-dates: 2001-10-21 00:00 is then interpreted as 2001-10-20 24:00.

formatDate

public String formatDate(Date date)
same as formatDate(date, false).

See Also:
formatDate(Date,boolean)


Copyright © 2000-2006 Rapla Team. All Rights Reseserved.