com.Ostermiller.util Java Utilities


com.Ostermiller.util
Class DateTimeParse

java.lang.Object
  extended by com.Ostermiller.util.DateTimeParse

public class DateTimeParse
extends Object

Parses a variety of formatted date strings with minimal configuration. Unlike other date parsers, there are no formats to specify. There is a single parse string method.

A wide variety of formats are supported:

Since:
ostermillerutils 1.08.00
Author:
Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities

Nested Class Summary
static class DateTimeParse.Field
           
 
Constructor Summary
DateTimeParse()
           
DateTimeParse(Locale locale)
           
 
Method Summary
 List<DateTimeParse.Field> getFieldOrder()
           
 Date parse(String dateString)
          Parse the given string into a Date.
 void setDefaultYear(int defaultYear)
          Set the default year to use when there is no year in the parsed date.
 void setFieldOrder(DateTimeParse.Field[] fieldOrder)
           
 void setFieldOrder(List<DateTimeParse.Field> fieldOrder)
           
 DateTimeParse setTimeZone(TimeZone zone)
           
 DateTimeParse setYearExtensionPolicy(YearExtensionPolicy yearExtensionPolicy)
          Set the year extension policy.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeParse

public DateTimeParse()

DateTimeParse

public DateTimeParse(Locale locale)
Method Detail

setFieldOrder

public void setFieldOrder(List<DateTimeParse.Field> fieldOrder)

setFieldOrder

public void setFieldOrder(DateTimeParse.Field[] fieldOrder)

getFieldOrder

public List<DateTimeParse.Field> getFieldOrder()

setDefaultYear

public void setDefaultYear(int defaultYear)
Set the default year to use when there is no year in the parsed date.

Since:
ostermillerutils 1.08.00

setYearExtensionPolicy

public DateTimeParse setYearExtensionPolicy(YearExtensionPolicy yearExtensionPolicy)
Set the year extension policy. This policy is responsible for extending two digit years into full years. eg. 99 to 1999

The default policy is YearExtensionAround.NEAREST. Several other policies are implemented:

Since:
ostermillerutils 1.08.00

parse

public Date parse(String dateString)
Parse the given string into a Date.

Parameters:
dateString - String with a date representation.
Returns:
timestamp represented by the date string, or null if the date could not be parsed.
Since:
ostermillerutils 1.08.00

setTimeZone

public DateTimeParse setTimeZone(TimeZone zone)

com.Ostermiller.util Java Utilities


Copyright © 2001-2012 by Stephen Ostermiller