public class DateTime
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
class |
DateTime.datetime |
| Constructor and Description |
|---|
DateTime() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Calendar |
changeDate(java.util.Calendar base,
int iChangeAmount) |
static java.util.Calendar |
changeDate(int iDay,
int iMonth,
int iYear,
int iChangeAmount) |
DateTime.datetime |
convertDateStringToDateTime(java.lang.String sDate) |
static java.lang.String |
formatDate(long datetime,
java.lang.String pattern)
Format the output for date time using SimpleDateFormat
Customized Date and Time Formats Pattern Output dd.MM.yy 09.04.98 yyyy.MM.dd G 'at' hh:mm:ss z 1998.04.09 AD at 06:15:55 PDT EEE, MMM d, ''yy Thu, Apr 9, '98 h:mm a 6:15 PM H:mm 18:15 H:mm:ss:SSS 18:15:55:624 K:mm a,z 6:15 PM,PDT yyyy.MMMMM.dd GGG hh:mm aaa 1998.April.09 AD 06:15 PM |
static java.lang.String |
getAbbDayText(int iDayOfWeek) |
static java.lang.String |
getAbbMonthText(int monthNum)
Get abbreviated month text.
|
static java.lang.String |
getDate()
Convert the current time in milliseconds to a string.
|
static java.lang.String |
getDate(long milliseconds)
Convert a time in milliseconds to a string.
|
static java.lang.String |
getDate(long milliseconds,
java.lang.String outFormat)
Convert a time in string format to milliseconds
The recognised formats are: 'dd' = day 'mo' = month 'MO' = abbreviated month text 'yy' = year 'YY' = year (2 digit) 'hh' = hour 'mm' = minute 'ss' = sec '..' = milli |
static java.lang.String |
getDate(long milliseconds,
java.lang.String dateSeperator,
java.lang.String timeSeperator)
Convert a time in milliseconds to a string.
|
static long |
getDate(java.lang.String date,
java.lang.String inFormat)
Convert a time in string format to milliseconds
The recognised formats are: 'dd' = day 'mo' = month 'MO' = abbreviated month text 'yy' = year 'YY' = year (2 digit) 'hh' = hour 'mm' = minute 'ss' = sec '..' = millisecond |
static java.lang.String |
getDate(java.lang.String date,
java.lang.String inFormat,
java.lang.String outFormat)
Convert a time in string format to milliseconds
The recognised formats are: 'dd' = day 'mo' = month 'MO' = abbreviated month text 'yy' = year 4 digit 'YY' = year (2 digit) 'hh' = hour 'mm' = minute 'ss' = sec |
static long |
getDateInMillis()
gets the current time on milliseconds
|
static int |
getDayOfWeek(int iDay,
int iMonth,
int iYear) |
static int |
getDaysInMonth(int iMonth,
int iYear) |
static java.lang.String |
getDayText(int iDayOfWeek) |
static int |
getMonthFromAbbText(java.lang.String month)
Get month number from abbreviated month text.
|
static int |
getMonthNumber(java.lang.String sMonthOfYear)
Convert a month in string format (January) to a number.
|
static java.lang.String |
getMonthText(int monthNum)
Get month text.
|
static java.lang.String |
getSQLDateFormat(int day,
int month,
int year,
java.lang.String time)
Get the database format for storing a date.
|
static java.lang.String |
getSQLDateFormat(java.lang.String sDay,
java.lang.String sMonth,
java.lang.String sYear,
java.lang.String sTime)
Get the database format for storing a date.
|
static boolean |
isLeapYear(int iYear) |
java.lang.String |
milliTimeToFullShowTime(long milliTime)
Convert a millisecond time to HH:MM:SS:MMMM
|
static java.lang.String |
milliTimeToShowTime(long milliTime)
Convert a millisecond time to HH:MM:SS
|
java.lang.String |
out_getDate(long milliseconds,
java.lang.String format)
Convert a time in milliseconds to a string.
The recognised formats are: 'dd' = day 'mo' = month 'MO' = abbreviated month text 'yy' = year 'YY' = year (2 digit) 'hh' = hour 'mm' = minute 'ss' = sec |
static java.lang.String |
validateDate(java.lang.String date,
java.lang.String format)
Validates the a date string.
|
public static int getDaysInMonth(int iMonth,
int iYear)
iMonth - ranging from 0-11 not 1-12iYear - 4 digits as in 2001 and not 01get the number of days in a month
public static boolean isLeapYear(int iYear)
iYear - 4 digits as in 2001 and not 01check if the entered year is a leap year
public static int getDayOfWeek(int iDay,
int iMonth,
int iYear)
iDay - ranging from 1-28/31iMonth - ranging from 0-11 not 1-12iYear - 4 digits as in 2001 and not 01get the day of the week 1 - 7. Developer must ensure the validity of the parameters entered.
public static java.util.Calendar changeDate(int iDay,
int iMonth,
int iYear,
int iChangeAmount)
iDay - ranging from 1-28/31iMonth - ranging from 0-11 not 1-12iYear - 4 digits as in 2001 and not 01iChangeAmount - is the number of days to change the date by.Change the date by a number of days.
public static java.util.Calendar changeDate(java.util.Calendar base,
int iChangeAmount)
base - is the base dateiChangeAmount - amount to change date by in daysChange the date by a number of days.
public static long getDateInMillis()
public static java.lang.String getDate()
public static java.lang.String getDate(long milliseconds)
milliseconds - is the time in milliseconds.public static java.lang.String getDate(long milliseconds,
java.lang.String dateSeperator,
java.lang.String timeSeperator)
milliseconds - is the time in milliseconds.dateSeperator - is the seperator char to use between year mon daytimeSeperator - is the seperator char to use between hour min secpublic java.lang.String out_getDate(long milliseconds,
java.lang.String format)
milliseconds - is the time in milliseconds.format - is the format of the date we want returned, i.e. dd-MO-yy hh:mm:ss = day number,
MO = month as text etc. 'dd' = day, 'mo' = month, 'MO' = month text
'yy' = year, 'hh' = hour, 'mm' = minute, 'ss' = secpublic static java.lang.String getDate(long milliseconds,
java.lang.String outFormat)
milliseconds - is the date we want convertedoutFormat - is the format of the date we want returned, i.e. dd-MO-yy hh:mm:ss = day number,
MO = month as text etc. 'dd' = day, 'mo' = month, 'MO' = month text
'yy' = year, 'hh' = hour, 'mm' = minute, 'ss' = sec, '..' = millisecondpublic static long getDate(java.lang.String date,
java.lang.String inFormat)
date - is the date we want converted to millisecondsinFormat - is the format of the date we want returned, i.e. dd-MO-yy hh:mm:ss = day number,
MO = month as text etc. 'dd' = day, 'mo' = month, 'MO' = month text
'yy' = year, 'hh' = hour, 'mm' = minute, 'ss' = sec, '..' = millisecondpublic static java.lang.String getDate(java.lang.String date,
java.lang.String inFormat,
java.lang.String outFormat)
throws java.lang.Exception
date - is the date we want converted to millisecondsinFormat - is the format of the date we want returned, i.e. dd-MO-yy hh:mm:ss = day number,
MO = month as text etc. 'dd' = day, 'mo' = month, 'MO' = month text
'yy' = year, 'hh' = hour, 'mm' = minute, 'ss' = secoutFormat - is the format of the date we want returned, i.e. dd-MO-yy hh:mm:ss = day number,
MO = month as text etc. 'dd' = day, 'mo' = month, 'MO' = month text
'yy' = year, 'hh' = hour, 'mm' = minute, 'ss' = secjava.lang.Exceptionpublic static java.lang.String getMonthText(int monthNum)
Get month text.
monthNum - between 0 and 11public static java.lang.String getDayText(int iDayOfWeek)
public static java.lang.String getAbbDayText(int iDayOfWeek)
public static java.lang.String getAbbMonthText(int monthNum)
Get abbreviated month text.
monthNum - between 0 and 11public static int getMonthFromAbbText(java.lang.String month)
Get month number from abbreviated month text. This is an ignoreCase comparision.
month - abbreviated format for month like "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"public static java.lang.String getSQLDateFormat(int day,
int month,
int year,
java.lang.String time)
Get the database format for storing a date.
day - = day of monthmonth - = month of yearyear - = yeartime - = time between 0:0:0 and 23:59:59public static java.lang.String getSQLDateFormat(java.lang.String sDay,
java.lang.String sMonth,
java.lang.String sYear,
java.lang.String sTime)
Get the database format for storing a date.
sDay - = day of monthsMonth - = month of yearsYear - = yearsTime - = time between 0:0:0 and 23:59:59public static java.lang.String validateDate(java.lang.String date,
java.lang.String format)
date - is the date string we want to validateformat - is the expected format of the date string. The format
should contain a 'n' for a number, a 'l' for a letter and a 'x' for anything elsepublic static int getMonthNumber(java.lang.String sMonthOfYear)
Convert a month in string format (January) to a number.
sMonthOfYear - public static java.lang.String milliTimeToShowTime(long milliTime)
public java.lang.String milliTimeToFullShowTime(long milliTime)
public DateTime.datetime convertDateStringToDateTime(java.lang.String sDate)
sDate - is the date to set format = 'dd-mm-yyyy hh:mm:ss'public static java.lang.String formatDate(long datetime,
java.lang.String pattern)
datetime - pattern -