Package com.softwaremining.util
Class DateUtil
java.lang.Object
com.softwaremining.util.DateUtil
Provides DB2 date functions which can be used instead of making an expensive call to DB2 merely for its date/time handling features
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final int
dateOfInteger
(long days) Replacement for function 'date-of-integer' converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD).static final String
Returns the full date/timestatic final int
dayOfInteger
(long days) Replacement for function 'day-of-integer' in MicroFocusstatic String
returns a 10 digit date string in DB2 format : e.g.static String
returns a 26 digit date-time string in DB2 format : e.g.static String
getDb2TimeStamp
(ISMBean sqlca) returns a 26 digit date-time string in DB2 format : e.g.static String
SoftwareMining time Stamp yyyy-MM-dd.HH-mm-ss-SSS- used internally / for creating time-labeled output directoriesstatic final int
getYYYYOfYear
(int twoDigitYear) Translation of FUNCTION YEAR-TO-YYYY.static final int
integerOfDate
(long date) The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form.static final int
integerOfDate
(String date) The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form.static final int
integerOfDay
(long date) SAS 11.03.2009static String
toDb2DateFormat
(Timestamp timeStamp)
-
Constructor Details
-
DateUtil
public DateUtil()
-
-
Method Details
-
dateTo21Symbol
Returns the full date/time- Parameters:
d
- : date- Returns:
- . return date in format "200612051046048200000" YYYYMMDDHHmmssmillis..
-
integerOfDate
public static final int integerOfDate(long date) The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form.- Parameters:
date
- - Must be an integer of the form YYYYMMDD, whose value is retrieveed from the calculation (YYYY * 10,000) + (MM * 100) + DD, where: YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600, but not greater than 9999. MM represents a month and must be a positive integer less than 13. DD represents a day and must be a positive integer less than 32, provided that it is valid for the specified month and year combination.- Returns:
- - The returned value is an integer that is the number of days that the date represented by argument-1 succeeds December 31, 1600 in the Gregorian calendar.
-
integerOfDate
The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form.- Parameters:
date
- - Must be an integer of the form YYYYMMDD, whose value is retrieveed from the calculation (YYYY * 10,000) + (MM * 100) + DD, where: YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600, but not greater than 9999. MM represents a month and must be a positive integer less than 13. DD represents a day and must be a positive integer less than 32, provided that it is valid for the specified month and year combination.- Returns:
- - The returned value is an integer that is the number of days that the date represented by argument-1 succeeds December 31, 1600 in the Gregorian calendar.
-
integerOfDay
public static final int integerOfDay(long date) SAS 11.03.2009- Returns:
- returns number of days since December 31, 1600 for the date DATE.
-
dateOfInteger
public static final int dateOfInteger(long days) Replacement for function 'date-of-integer' converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD).- Parameters:
days
- - positive integer that represents a number of days succeeding December 31, 1600, in the Gregorian calendar. The valid range is 1 to 3,067,671, which corresponds to dates ranging from January 1, 1601 thru December 31, 9999.- Returns:
- - an integer of the form YYYYMMDD where YYYY represents a year in the Gregorian calendar; MM represents the month of that year; and DD represents the day of that month.
-
dayOfInteger
public static final int dayOfInteger(long days) Replacement for function 'day-of-integer' in MicroFocus -
getYYYYOfYear
public static final int getYYYYOfYear(int twoDigitYear) Translation of FUNCTION YEAR-TO-YYYY. Converts a 2 digit year to a 4 digit year- Parameters:
twoDigitYear
-- Returns:
- FourDigit Integer
-
getDb2TimeStamp
returns a 26 digit date-time string in DB2 format : e.g. "2016-02-02 11:12;12.123000"
Note: DB2 time functions contain 6 digit milli invalid input: '&' nano seconds. Java/C# only contain 3 digit milli seconds information. Hence the last 3 digits will be randomly assigned
This function can be used instead of calling the following SQL statement from COBOLSET :WS-DATE-TIME = CURRENT TIMESTAMP
Or from Java:SELECT CURRENT TIMESTAMP from FROM SYSIBM.SYSDUMMY1
- Returns:
-
getDb2TimeStamp
returns a 26 digit date-time string in DB2 format : e.g. "2016-02-02 11:12;12.123000"
Note: DB2 time functions contain 6 digit milli invalid input: '&' nano seconds. Java/C# only contain 3 digit milli seconds information. Hence the last 3 digits will always be 000 due to this limitation
This function can be used instead of calling the following SQL statement from COBOLSET :WS-DATE-TIME = CURRENT TIMESTAMP
Or from Java:SELECT CURRENT TIMESTAMP from FROM SYSIBM.SYSDUMMY1
- Returns:
-
getDb2Date
returns a 10 digit date string in DB2 format : e.g. "2016-02-02" This function can be used instead of calling the following SQL statement from COBOLSET :WS-DATE-TIME = CURRENT DATE
Or from Java:SELECT CURRENT DATE from FROM SYSIBM.SYSDUMMY1
- Returns:
-
toDb2DateFormat
-
getSMTimeStamp
SoftwareMining time Stamp yyyy-MM-dd.HH-mm-ss-SSS- used internally / for creating time-labeled output directories- Returns:
-