IMC Epclient 5.0.3

at.spardat.enterprise.util
Class DateUtil

java.lang.Object
  extended byat.spardat.enterprise.util.DateUtil

public class DateUtil
extends java.lang.Object

Some date utility functions. The valid date range is [1.1.0001, 31.12.9999], whereby the range [5.10.1582, 14.10.1582] is excluded. Until 4.10.1582, the Julian calendar is used (every 4th year is a leap year). Beginning at 15.10.1582, the Gregorian calender is put into action (still every 4th year is a leap year, without every 100th, and the exception from the exception is every 400th).

Many of the methods use string representations to denote a date, the format used is at any time YYYYMMDD.


Nested Class Summary
static class DateUtil.DMY
          Represents the components of a date.
 
Constructor Summary
DateUtil()
           
 
Method Summary
static java.lang.String date2Internal(java.util.Date d)
          Converts a java.util.Date to the internal format
static java.lang.String DMY2Internal(DateUtil.DMY dmy)
          Converts a DMY structure to the ISO format YYYYMMDD
static DateUtil.DMY getDMY(java.util.GregorianCalendar c)
          Returns components out of GregorianCalendar.
static java.util.Date internal2Date(java.lang.String internal)
          Converts the internal date format to a java.util.Date
static DateUtil.DMY internal2DMY(java.lang.String internal)
          Converts the ISO string YYYYMMDD to the components.
static java.util.GregorianCalendar internal2Gregorian(java.lang.String internal)
          Converts an YYYMMDD string to a newly created GregorianCalendar.
static boolean isLeapYear(int year)
          Calculates if a year is a leap year.
static boolean isValid(DateUtil.DMY dmy)
          Returns true if the provided components represent a valid date
static boolean isValid(java.lang.String internal)
          Checks if the provided String is a valid YYYYMMDD string.
static void resetTime(java.util.GregorianCalendar cal)
          Sets the time in the given cal to 00:00:00.000
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

isLeapYear

public static boolean isLeapYear(int year)
Calculates if a year is a leap year.

Parameters:
year - the input year
Returns:
true if leap year

isValid

public static boolean isValid(DateUtil.DMY dmy)
Returns true if the provided components represent a valid date


getDMY

public static DateUtil.DMY getDMY(java.util.GregorianCalendar c)
Returns components out of GregorianCalendar.

Parameters:
c - the input calendar
Returns:
a newly created DMY object

date2Internal

public static java.lang.String date2Internal(java.util.Date d)
Converts a java.util.Date to the internal format


internal2Date

public static java.util.Date internal2Date(java.lang.String internal)
Converts the internal date format to a java.util.Date


internal2DMY

public static DateUtil.DMY internal2DMY(java.lang.String internal)
Converts the ISO string YYYYMMDD to the components. Requires that internal is exactly 8 digits and that all digits are indeed digits.

Parameters:
internal - string following YYYYMMDD with isValid yielding true.
Returns:
newly created DMY object

isValid

public static boolean isValid(java.lang.String internal)
Checks if the provided String is a valid YYYYMMDD string. The syntax must be ok and the date must within the defined date range.


internal2Gregorian

public static java.util.GregorianCalendar internal2Gregorian(java.lang.String internal)
Converts an YYYMMDD string to a newly created GregorianCalendar.

Parameters:
internal - string following the syntax YYYYMMDD
Returns:
newly created GregorianCalendar

DMY2Internal

public static java.lang.String DMY2Internal(DateUtil.DMY dmy)
Converts a DMY structure to the ISO format YYYYMMDD

Returns:
string following YYYYMMDD

resetTime

public static void resetTime(java.util.GregorianCalendar cal)
Sets the time in the given cal to 00:00:00.000


IMC Epclient 5.0.3