org.tridas.io.util
Class DateUtils

java.lang.Object
  extended by org.tridas.io.util.DateUtils

public class DateUtils
extends Object


Constructor Summary
DateUtils()
           
 
Method Summary
static org.tridas.schema.Date dateTimeToDate(org.tridas.schema.DateTime dt)
          Convert from org.tridas.schema.DateTime to org.tridas.schema.Date
static org.tridas.schema.DateTime getDateTime(Integer day, Integer month, Integer year)
          Create a DateTime from the constituent day, month, year
static org.tridas.schema.DateTime getDateTime(Integer day, Integer month, Integer year, Integer hours, Integer minutes)
          Create a DateTime from the constituent day, month, year, hours and minutes
static org.tridas.schema.DateTime getDateTime(Integer day, Integer month, Integer year, Integer hours, Integer minutes, Integer seconds)
          Create a DateTime from the constituent day, month, year, hours, minutes and seconds
static org.tridas.schema.DateTime getDateTimeFromWinDendroTimestamp(String timestamp)
          Get a DateTime from a WinDendro style timestamp.
static String getDateTimePast4Style(org.tridas.schema.DateTime date)
          Converts a DateTime into a PAST4 style date string (dd/MM/yyyy h:mm:ss a).
static String getDateTimeTRIMSStyle(Date date)
          Converts a DateTime into a TRIMS style date string (dd/MM/yyyy).
static String getDateTimeTucsonStyle(org.tridas.schema.DateTime date)
          Converts a DateTime into a Tucson style date string (yyyyMMdd).
static String getFormattedDateTime(org.tridas.schema.DateTime date, SimpleDateFormat dateFormat)
          Converts a DateTime into a string formatted using the provided SimpleDateFormat
static org.tridas.schema.DateTime getTodaysDateTime()
          Create a DateTime for right now
static org.tridas.schema.DateTime parseDateFromDayMonthYearString(String date)
          Try and parse a DateTime from a string.
static org.tridas.schema.DateTime parseDateFromPast4String(String date)
          Parse a DateTime from a PAST4 format string (dd/MM/yyyy hh:mm)
static org.tridas.schema.DateTime parseDateTimeFromNaturalString(String str)
          Attempt to parse a DateTime from a natural language string using the Natty library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtils

public DateUtils()
Method Detail

getTodaysDateTime

public static org.tridas.schema.DateTime getTodaysDateTime()
Create a DateTime for right now

Returns:

getDateTime

public static org.tridas.schema.DateTime getDateTime(Integer day,
                                                     Integer month,
                                                     Integer year)
Create a DateTime from the constituent day, month, year

Parameters:
day -
month -
year -
hours -
minutes -
Returns:

getDateTime

public static org.tridas.schema.DateTime getDateTime(Integer day,
                                                     Integer month,
                                                     Integer year,
                                                     Integer hours,
                                                     Integer minutes)
Create a DateTime from the constituent day, month, year, hours and minutes

Parameters:
day -
month -
year -
hours -
minutes -
Returns:

getDateTime

public static org.tridas.schema.DateTime getDateTime(Integer day,
                                                     Integer month,
                                                     Integer year,
                                                     Integer hours,
                                                     Integer minutes,
                                                     Integer seconds)
Create a DateTime from the constituent day, month, year, hours, minutes and seconds

Parameters:
day -
month -
year -
hours -
minutes -
seconds -
Returns:

getDateTimeFromWinDendroTimestamp

public static org.tridas.schema.DateTime getDateTimeFromWinDendroTimestamp(String timestamp)
Get a DateTime from a WinDendro style timestamp. String should be of the format: d/m/yyyy kk:mm

Parameters:
timestamp -
Returns:

parseDateFromDayMonthYearString

public static org.tridas.schema.DateTime parseDateFromDayMonthYearString(String date)
                                                                  throws Exception
Try and parse a DateTime from a string. Supported styles are: - dd/MM/yy - dd.MM.yy - dd-MM-yy - ddMMyyyy For two digit years, yy>50 is interpreted as 19xx, and yy<50 is interpreted as 20xx All other formats return null.

Parameters:
date -
Returns:
Throws:
Exception

getDateTimeTucsonStyle

public static String getDateTimeTucsonStyle(org.tridas.schema.DateTime date)
Converts a DateTime into a Tucson style date string (yyyyMMdd). If the supplied date is null, then it returns the correct string for todays date.

Parameters:
date -
Returns:

getFormattedDateTime

public static String getFormattedDateTime(org.tridas.schema.DateTime date,
                                          SimpleDateFormat dateFormat)
Converts a DateTime into a string formatted using the provided SimpleDateFormat

Parameters:
date -
format - SimpleDateFormat
Returns:

getDateTimePast4Style

public static String getDateTimePast4Style(org.tridas.schema.DateTime date)
Converts a DateTime into a PAST4 style date string (dd/MM/yyyy h:mm:ss a). If the supplied date is null, then it returns the correct string for todays date.

Parameters:
date -
Returns:

getDateTimeTRIMSStyle

public static String getDateTimeTRIMSStyle(Date date)
Converts a DateTime into a TRIMS style date string (dd/MM/yyyy). If the supplied date is null, then it returns the correct string for todays date.

Parameters:
date -
Returns:

parseDateFromPast4String

public static org.tridas.schema.DateTime parseDateFromPast4String(String date)
                                                           throws Exception
Parse a DateTime from a PAST4 format string (dd/MM/yyyy hh:mm)

Parameters:
date -
Returns:
Throws:
Exception

parseDateTimeFromNaturalString

public static org.tridas.schema.DateTime parseDateTimeFromNaturalString(String str)
Attempt to parse a DateTime from a natural language string using the Natty library. This has various limitations including being English specific.

Parameters:
str -
Returns:

dateTimeToDate

public static org.tridas.schema.Date dateTimeToDate(org.tridas.schema.DateTime dt)
Convert from org.tridas.schema.DateTime to org.tridas.schema.Date

Parameters:
dt -
Returns:


Copyright © 2011. All Rights Reserved.