org.apache.lucene.gdata.utils
Class DateFormater

java.lang.Object
  extended by org.apache.lucene.gdata.utils.DateFormater

public class DateFormater
extends Object

This class uses the SimpleDateFormat class to format dates into strings according to given date pattern.

As the creation of SimpleDateFormat objects is quiet expensive and formating dates is used quiet fequently the objects will be cached and reused in subsequent calls.

This implementation is thread safe as it uses Stack as a cache

Author:
Simon Willnauer

Field Summary
static String HTTP_HEADER_DATE_FORMAT
          Date format as it is used in Http Last modified header (Tue, 15 Nov 1994 12:45:26 GMT)
static String HTTP_HEADER_DATE_FORMAT_TIME_OFFSET
          Date format as it is used in Http Last modified header (Tue, 15 Nov 1994 12:45:26 +0000)
 
Constructor Summary
protected DateFormater()
           
 
Method Summary
static String formatDate(Date date, String format)
          Formats the given Date into the given date pattern.
protected  SimpleDateFormat getFormater()
           
static Date parseDate(String date, String... formates)
          Parses the given string into one of the specified formates
static Date parseDate(String dateString, String pattern)
          Parses the given string into the specified formate
protected  void returnFomater(SimpleDateFormat format)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_HEADER_DATE_FORMAT

public static final String HTTP_HEADER_DATE_FORMAT
Date format as it is used in Http Last modified header (Tue, 15 Nov 1994 12:45:26 GMT)

See Also:
Constant Field Values

HTTP_HEADER_DATE_FORMAT_TIME_OFFSET

public static final String HTTP_HEADER_DATE_FORMAT_TIME_OFFSET
Date format as it is used in Http Last modified header (Tue, 15 Nov 1994 12:45:26 +0000)

See Also:
Constant Field Values
Constructor Detail

DateFormater

protected DateFormater()
Method Detail

formatDate

public static String formatDate(Date date,
                                String format)
Formats the given Date into the given date pattern.

Parameters:
date - - the date to format
format - - date pattern
Returns:
- the string representation of the given Date according to the given pattern

parseDate

public static Date parseDate(String date,
                             String... formates)
                      throws ParseException
Parses the given string into one of the specified formates

Parameters:
date - - the string to parse
formates - - formates
Returns:
a Date instance representing the given string
Throws:
ParseException - - if the string can not be parsed

parseDate

public static Date parseDate(String dateString,
                             String pattern)
                      throws ParseException
Parses the given string into the specified formate

Parameters:
dateString - - the string to parse
pattern - - the expected formate
Returns:
a Date instance representing the given string
Throws:
ParseException - - if the string can not be parsed

getFormater

protected SimpleDateFormat getFormater()

returnFomater

protected void returnFomater(SimpleDateFormat format)


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.