com.ecebs.rtd.enabler.common
Class CalendarUtils

java.lang.Object
  extended by com.ecebs.rtd.enabler.common.CalendarUtils

public class CalendarUtils
extends Object

Provides methods to aide in creating and parsing dates obtained from RTD. Also helps in parsing dates from IPE data.

Author:
kyleb

Method Summary
static Calendar byteArrayToDTS(byte[] sourceArray, int sourceIndex)
          Parses 3 bytes from the sourceArray, starting at the sourceIndex, and uses that to create an ITSO DTS
static Calendar createITSOBaseDate()
          Create a new instance of a calendar set to the ITSO base date
static Calendar createITSODate(int days)
          Creates an ITSO date instance set to the specified number of days since the ITSO base date (01/01/1997)
static String getFormattedDate(Calendar calendar, String format)
          Create a string representation of a date and time in the format specified
static String getRTDSFormattedDate(Calendar calendar)
          Create a string representation of a date in the format required by RTD
static String getRTDSFormattedDateWithTime(Calendar calendar)
          Create a string representation of a date and time in the format required by RTD
static boolean isITSOBaseDate(Calendar dts)
          Check if a calendar instance is set to the ITSO base date
static Calendar parseRTDDate(String dts)
          Creates a calendar instance from the provided string.
static Calendar parseRTDDateWithTime(String dts)
          Creates a calendar instance from the provided string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRTDSFormattedDate

public static String getRTDSFormattedDate(Calendar calendar)
Create a string representation of a date in the format required by RTD

Parameters:
calendar - Instance to be converted
Returns:
String representation of date

getRTDSFormattedDateWithTime

public static String getRTDSFormattedDateWithTime(Calendar calendar)
Create a string representation of a date and time in the format required by RTD

Parameters:
calendar - Instance to be converted
Returns:
String representation of date and time

getFormattedDate

public static String getFormattedDate(Calendar calendar,
                                      String format)
Create a string representation of a date and time in the format specified

Parameters:
calendar - Instance to be converted
format - Format of the string to be returned, in Formatter date/time format syntax
Returns:
String representation of date and time

createITSOBaseDate

public static Calendar createITSOBaseDate()
Create a new instance of a calendar set to the ITSO base date

Returns:
Calendar instance set to 01/01/1997, 00:00:00 GMT

isITSOBaseDate

public static boolean isITSOBaseDate(Calendar dts)
Check if a calendar instance is set to the ITSO base date

Parameters:
dts - Instance to check
Returns:
true if set to ITSO base date, else false

parseRTDDateWithTime

public static Calendar parseRTDDateWithTime(String dts)
                                     throws ParseException
Creates a calendar instance from the provided string. The string must be of the foramt "yyyy-MM-dd'T'HH:mm:ss", i.e. 2011-01-23T01:02:03

Parameters:
dts - String to parse
Returns:
Created calendar instance
Throws:
ParseException - Thrown if the string was not in the required format

parseRTDDate

public static Calendar parseRTDDate(String dts)
                             throws ParseException
Creates a calendar instance from the provided string. The string must be of the foramt "yyyy-MM-dd", i.e. 2011-01-23

Parameters:
dts - String to parse
Returns:
Created calendar instance
Throws:
ParseException - Thrown if the string was not in the required format

byteArrayToDTS

public static Calendar byteArrayToDTS(byte[] sourceArray,
                                      int sourceIndex)
Parses 3 bytes from the sourceArray, starting at the sourceIndex, and uses that to create an ITSO DTS

Parameters:
sourceArray - Array to read bytes from
sourceIndex - Position to start reading
Returns:
The created DTS

createITSODate

public static Calendar createITSODate(int days)
Creates an ITSO date instance set to the specified number of days since the ITSO base date (01/01/1997)

Parameters:
days - Number of days to add
Returns:
The created date instance


Copyright © 2013 Ecebs Ltd. All Rights Reserved.