public class dateUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
NUMSECSINDY |
static int |
NUMSECSINHR |
static int |
NUMSECSINMN |
static int |
NUMSECSINWK |
static int |
NUMSECSINYR |
| Constructor and Description |
|---|
dateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
calcNumDays(java.lang.String date)
Calculate the number of days elapsed for a given
date (e.g.
|
static java.sql.Date |
convertDateObj(java.lang.String dateStr,
IfxConnection conn)
Determine the localized java.sql.Date object of a date string based on a
char or varchar date string representation.
|
static java.lang.String |
convertDateStr(java.sql.Date date,
IfxConnection conn)
Determine the localized date format of a date string based on a
java.sql.Date object.
|
static java.lang.String |
convertDateTimeStr(java.util.Date datetime,
IfxConnection conn,
long value)
Determine the localized date format of a datetime/time string based on a
java.sql.Timestamp/java.sql.Time object.
|
static java.lang.String |
convertNativeSQLDate(java.lang.String dateStr,
IfxConnection conn)
Determine the localized date format of a date string whose original
representation was in NativeSQL JDBC escape format "yyyy-mm-dd'.
|
static java.lang.String |
convertNativeSQLDateTime(java.lang.String datetimeStr,
IfxConnection conn,
boolean isTime)
Determine the localized datetime format of a datetime string whose original
representation was in NativeSQL JDBC escape format 'yyyy-mm-dd hh:mm:ss[.fffff]'
(for datetime) or 'hh:mm:ss' (for time).
|
static java.sql.Time |
convertStringToTime(java.lang.String timeStr,
IfxConnection conn)
Converts the given string to a Time object
|
static java.sql.Timestamp |
convertStringToTimestamp(java.lang.String datetimeStr,
IfxConnection conn)
Converts the given string to a Time object
|
static java.util.GregorianCalendar |
getCurrentDateGC(IfxConnection conn) |
static java.util.Locale |
getLocaleValue(java.lang.String dateLocale)
Determine the correct locale setting based on whether a server is
a GLS server or not.
|
static long |
gregToJulian(java.lang.String date)
Given a valid date ('yyyy-mm-dd' format), calculate
the julian day of that date.
|
static boolean |
isLeapYear(int year)
Determine if the given year is a leap year or not.
|
static boolean |
isValidDate(int year,
int month,
int day)
Verify that the date is valid based on year, month and day provided
|
static boolean |
isValidDate(java.lang.String date)
Verify that the input string is a valid date value.
|
static boolean |
isValidTime(java.lang.String time)
Verify that the input string is a valid time value.
|
static boolean |
isValidTimeStamp(java.lang.String timeStamp)
Verify that the input string is a valid timestamp value.
|
static java.lang.String |
trimExcessTimestampFraction(java.lang.String s)
Informix only supports up to 5 digits in the fractions
of a second field (frac(5)).
|
public static final int NUMSECSINHR
public static final int NUMSECSINDY
public static final int NUMSECSINWK
public static final int NUMSECSINMN
public static final int NUMSECSINYR
public static int calcNumDays(java.lang.String date)
a - string representation of a datepublic static boolean isValidTimeStamp(java.lang.String timeStamp)
a - string representation of a timestamppublic static java.lang.String trimExcessTimestampFraction(java.lang.String s)
a - string representation of a timestamppublic static boolean isValidTime(java.lang.String time)
a - string representation of a timepublic static boolean isValidDate(java.lang.String date)
a - string representation of a datepublic static long gregToJulian(java.lang.String date)
public static boolean isLeapYear(int year)
integer - representation of a yearpublic static java.util.Locale getLocaleValue(java.lang.String dateLocale)
dateLocale - a string representation of
the current client or database localepublic static java.lang.String convertNativeSQLDate(java.lang.String dateStr,
IfxConnection conn)
throws java.sql.SQLException
dateStr - - a string representation of a date in "yyyy-mm-dd"
JDBC escape format.conn - - the current connection object.java.sql.SQLExceptionpublic static java.lang.String convertNativeSQLDateTime(java.lang.String datetimeStr,
IfxConnection conn,
boolean isTime)
throws java.sql.SQLException
datetimeStr - - a string representation of a datetime in
"yyyy-mm-dd hh:mm:ss[.fffff]" (for datetime) or
"hh:mm:ss" (for time) JDBC escape format.conn - - the current connection object.isTime - - true represents java.sql.Time, false represents
java.sql.Timestampjava.sql.SQLExceptionpublic static java.lang.String convertDateStr(java.sql.Date date,
IfxConnection conn)
throws java.sql.SQLException
date - - java.sql.Date object representationconn - - the current connection object.java.sql.SQLExceptionpublic static java.lang.String convertDateTimeStr(java.util.Date datetime,
IfxConnection conn,
long value)
throws java.sql.SQLException
datetime - - java.sql.Timestamp or java.sql.Time object
representationconn - - the current connection object.value - - long integer representation of datetime value.java.sql.SQLExceptionpublic static java.sql.Date convertDateObj(java.lang.String dateStr,
IfxConnection conn)
throws java.sql.SQLException
dateStr - - a string representation of a date value.conn - - the current connection object.java.sql.SQLExceptionpublic static java.sql.Timestamp convertStringToTimestamp(java.lang.String datetimeStr,
IfxConnection conn)
throws java.sql.SQLException
datetimeStr - Input Stringconn - Informix Connectionjava.sql.SQLExceptionpublic static java.sql.Time convertStringToTime(java.lang.String timeStr,
IfxConnection conn)
throws java.sql.SQLException
timeStr - Input Stringconn - Informix Connectionjava.sql.SQLExceptionpublic static java.util.GregorianCalendar getCurrentDateGC(IfxConnection conn) throws java.sql.SQLException
java.sql.SQLExceptionpublic static boolean isValidDate(int year,
int month,
int day)
int - year, int month, int day