ucar.nc2.units
Class DateFormatter

java.lang.Object
  extended by ucar.nc2.units.DateFormatter

public class DateFormatter
extends Object

Date parsing and formatting. Always uses GMT. These are not thread-safe.

Author:
caron

Constructor Summary
DateFormatter()
           
 
Method Summary
 Date dateOnlyFormat(String text)
          Parse text in the format "yyyy-MM-dd"
 Date getISODate(String text)
          Parse the text in W3C profile of ISO 8601 format.
 String getStandardDateOnlyString(Date date)
          Deprecated. use toDateOnlyString
 String getStandardDateString(Date date)
          Deprecated. use toDateTimeStringISO
 String getStandardDateString2(Date date)
          Deprecated. use toDateTimeString
 Date isoDateNoSecsFormat(String text)
          Parse text in the format "yyyy-MM-dd'T'HH:mm"
 Date isoDateTimeFormat(String text)
          Parse text in the format "yyyy-MM-dd'T'HH:mm:ss"
static void main(String[] args)
          test
 Date stdDateNoSecsFormat(String text)
          Parse text in the format "yyyy-MM-dd HH:mm"
 Date stdDateTimeFormat(String text)
          Parse text in the format "yyyy-MM-dd HH:mm:ss"
 String toDateOnlyString(Date date)
          date only format= yyyy-MM-dd
 String toDateString(Date date)
          Deprecated. use toDateOnlyString
 String toDateTimeString(Date date)
          "standard date format" = yyyy-MM-dd HH:mm:ssZ
 String toDateTimeStringISO(Date date)
          "ISO date format" = yyyy-MM-dd'T'HH:mm:ssZ
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatter

public DateFormatter()
Method Detail

getISODate

public Date getISODate(String text)
Parse the text in W3C profile of ISO 8601 format.

Parameters:
text - parse this text
Returns:
equivalent Date or null if failure
See Also:
W3C profile of ISO 8601

stdDateTimeFormat

public Date stdDateTimeFormat(String text)
                       throws ParseException
Parse text in the format "yyyy-MM-dd HH:mm:ss"

Parameters:
text - parse this text
Returns:
equivalent Date
Throws:
ParseException - if not formatted correctly

stdDateNoSecsFormat

public Date stdDateNoSecsFormat(String text)
                         throws ParseException
Parse text in the format "yyyy-MM-dd HH:mm"

Parameters:
text - parse this text
Returns:
equivalent Date
Throws:
ParseException - if not formatted correctly

isoDateTimeFormat

public Date isoDateTimeFormat(String text)
                       throws ParseException
Parse text in the format "yyyy-MM-dd'T'HH:mm:ss"

Parameters:
text - parse this text
Returns:
equivalent Date
Throws:
ParseException - if not formatted correctly

isoDateNoSecsFormat

public Date isoDateNoSecsFormat(String text)
                         throws ParseException
Parse text in the format "yyyy-MM-dd'T'HH:mm"

Parameters:
text - parse this text
Returns:
equivalent Date
Throws:
ParseException - if not formatted correctly

dateOnlyFormat

public Date dateOnlyFormat(String text)
                    throws ParseException
Parse text in the format "yyyy-MM-dd"

Parameters:
text - parse this text
Returns:
equivalent Date
Throws:
ParseException - if not formatted correctly

getStandardDateOnlyString

public String getStandardDateOnlyString(Date date)
Deprecated. use toDateOnlyString

Return standard GMT date format; show date only, not time. Format = "yyyy-MM-dd"


toDateString

public String toDateString(Date date)
Deprecated. use toDateOnlyString

date only format= yyyy-MM-dd


toDateOnlyString

public String toDateOnlyString(Date date)
date only format= yyyy-MM-dd

Parameters:
date - format this date
Returns:
date formatted as date only

getStandardDateString2

public String getStandardDateString2(Date date)
Deprecated. use toDateTimeString

Return standard formatted GMT date and time String. Format = "yyyy-MM-dd HH:mm:ss'Z'"


toDateTimeString

public String toDateTimeString(Date date)
"standard date format" = yyyy-MM-dd HH:mm:ssZ

Parameters:
date - format this date
Returns:
date formatted as date/time

getStandardDateString

public String getStandardDateString(Date date)
Deprecated. use toDateTimeStringISO

Return standard formatted GMT date and time String. Format = "yyyy-MM-dd'T'HH:mm:ss'Z'"


toDateTimeStringISO

public String toDateTimeStringISO(Date date)
"ISO date format" = yyyy-MM-dd'T'HH:mm:ssZ

Parameters:
date - format this date
Returns:
date formatted as ISO date string

main

public static void main(String[] args)
test



Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.