org.ipdr.utils
Class TimeUtil

java.lang.Object
  extended by org.ipdr.utils.TimeUtil

public class TimeUtil
extends java.lang.Object

This class is added to include the method for conversion of seconds / milliseconds / microseconds to prescribed formats in XML and back.


Constructor Summary
TimeUtil()
           
 
Method Summary
static int convDateTimeToInt(java.lang.String strDateTime)
          This method takes the time in the form of DateTime string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into long data type.
static java.lang.String convIntToDateTime(int timeSec)
          This method takes the time in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.0 specification.
static java.lang.String convLongToMSec(long timeMilliSec)
          This method takes the time (in milliseconds) in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.0 specification.
static java.lang.String convLongToUSec(long microSec)
          This method takes the time (in microseconds) in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.5 specification.
static long convMSecToLong(java.lang.String strTime)
          This method takes the time in the form of string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into milliseconds specified by a long data type.
static long convUSecToLong(java.lang.String strTime)
          This method takes the time in the form of string format as per pattern specified in the NDM-U 3.5 specification as input and converts it into microseconds specified by a long data type.
protected static int dateValidation(java.lang.String date)
          This method takes date String as specified in NDM-U 3.0 as input and checks for valid date and valid time.
protected static int daysInFeb(int year)
          This method takes year as input parameter and returns number of days in a leap year for the month of February.
protected static int getDaysOfMonth(int month, int year)
          This method takes month and year as input parameter and returns number of days in the month.
protected static int isValidDate(java.lang.String date)
          This method takes date String as specified in NDM-U 3.0 as input and checks for valid date and valid time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeUtil

public TimeUtil()
Method Detail

convLongToMSec

public static java.lang.String convLongToMSec(long timeMilliSec)
This method takes the time (in milliseconds) in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.0 specification.

Parameters:
timeMilliSec - Time as long data type
Returns:
Time string as specified in NDM-U 3.0

convMSecToLong

public static long convMSecToLong(java.lang.String strTime)
                           throws IPDRException
This method takes the time in the form of string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into milliseconds specified by a long data type. Date validation is also done.

Parameters:
strTime - Time in String format
Returns:
Time in long data type
Throws:
IPDRException

convIntToDateTime

public static java.lang.String convIntToDateTime(int timeSec)
This method takes the time in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.0 specification.

Parameters:
timeSec - Time as long data type
Returns:
Time string as specified in NDM-U 3.0

convDateTimeToInt

public static int convDateTimeToInt(java.lang.String strDateTime)
                             throws IPDRException
This method takes the time in the form of DateTime string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into long data type. Date validation is also done.

Parameters:
strDateTime - Time in String format
Returns:
Time in long data type
Throws:
IPDRException

convLongToUSec

public static java.lang.String convLongToUSec(long microSec)
This method takes the time (in microseconds) in the form of long data type as input and converts it into string format as per pattern specified in the NDM-U 3.5 specification.

Parameters:
microSec - Time as long data type
Returns:
Time string as specified in NDM-U 3.5

convUSecToLong

public static long convUSecToLong(java.lang.String strTime)
                           throws IPDRException
This method takes the time in the form of string format as per pattern specified in the NDM-U 3.5 specification as input and converts it into microseconds specified by a long data type. Date validation is also done.

Parameters:
strTime - Time in String format
Returns:
Time in long data type
Throws:
IPDRException

isValidDate

protected static int isValidDate(java.lang.String date)
                          throws IPDRException
This method takes date String as specified in NDM-U 3.0 as input and checks for valid date and valid time. Number of days in a month are obtained from getDaysOfMonth().

Parameters:
date - Date String as specified in NDM-U 3.0
Returns:
Valid / Invalid (0/1)
Throws:
IPDRException

dateValidation

protected static int dateValidation(java.lang.String date)
                             throws IPDRException
This method takes date String as specified in NDM-U 3.0 as input and checks for valid date and valid time. Number of days in a month are obtained from getDaysOfMonth().

Parameters:
date - Date String as specified in NDM-U 3.0
Returns:
Valid / Invalid (0/1)
Throws:
IPDRException

getDaysOfMonth

protected static int getDaysOfMonth(int month,
                                    int year)
This method takes month and year as input parameter and returns number of days in the month. Number of days in a leap year are obtained from isLeapYear().

Parameters:
month - Month as integer
year - Year as integer
Returns:
Days Of Month

daysInFeb

protected static int daysInFeb(int year)
This method takes year as input parameter and returns number of days in a leap year for the month of February.

Parameters:
year - Year as integer
Returns:
Number of days in February