public class DateFormat
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
FRIDAY
constant value for Friday.
|
static int |
MONDAY
constant value for Monday.
|
static int |
SATURDAY
constant value for Saturday.
|
static int |
SUNDAY
constant value for Sunday.
|
static int |
THURSDAY
constant value for Thursday.
|
static long |
TIME_PER_DAY
millis per day.
|
static int |
TUESDAY
constant value for Tuesday.
|
static int |
WEDNESDAY
constant value for Wednesday.
|
Constructor and Description |
---|
DateFormat(java.lang.String format)
This constructor deals with various date formats.
|
DateFormat(java.lang.String format,
int tz)
Constructor DateFormat.
|
Modifier and Type | Method and Description |
---|---|
static long |
addMonths(long t,
int months)
Add the count of months to the time value.
|
static byte[] |
ba_dd_MMM_yyyy_HH_mm_ss_zzzz(long l)
Return a byte array for the given date (long) in format
dd/MMM/yyyy:HH:mm:ss +zz:zz . |
static byte[] |
ba_EEE__dd_MMM_yyyy_HH_mm_ss_GMT(long l)
Return a byte array for the given date (long) in format
EEE, dd MMM yyyy HH:mm:ss GMT . |
static int[] |
calc(long l)
Creates an array of int[8] with all time elements.
|
static int[] |
calc(long l,
int timeZone)
Creates an array of int[8] with all time elements.
|
static java.lang.String |
dd_MMM_yyyy_HH_mm_ss_GMT_zz_zz(long l)
Return a String for the given date (long) in format
dd/MMM/yyyy:HH:mm:ss GMT+zz:zz . |
static java.lang.String |
dd_MMM_yyyy_HH_mm_ss_zzzz(long l)
Return a String for the given date (long) in format
dd/MMM/yyyy:HH:mm:ss +zz:zz . |
static java.lang.String |
ddMMyyyy(long l)
Return a String for the given date (long) in format ddMMyyyy.
|
static java.lang.String |
ddMMyyyyHHmmss(long l)
Return a String for the given date (long) in format ddMMyyyyHHmmss.
|
static long |
eastern(int year)
Calculates the easter day for a given year > 1970.
|
static java.lang.String |
EEE__dd_MMM_yyyy_HH_mm_ss__zzzz(long l)
Return a String for the given date (long) in format
EEE, dd MMM yyyy HH:mm:ss +zzzz . |
static java.lang.String |
EEE__dd_MMM_yyyy_HH_mm_ss_GMT(long l)
Return a String for the given date (long) in format
EEE, dd MMM yyyy HH:mm:ss GMT . |
static long |
firstOfDay(long t)
Returns a time value for the specified day at 00:00:00.000 with current time zone.
|
static long |
firstOfMonth(long date)
Returns the value for the first day in date's month.
|
static long |
firstOfWeek(long time)
get the first day of the corresponding week.
|
static long |
firstOfYear(long date)
Returns the value for the first day in date's year.
|
java.lang.String |
format(long time)
Returns the formatted String using the format String specified at the constructor.
|
static int |
getDayOfMonth(long date)
Method getDayOfMonth.
|
java.lang.String |
getMask()
Returns the current fill bytes.
|
static int |
getMonth(long t)
the month the given date.
|
static int |
getWeek(long time)
Method getWeek returns the week number for the supplied date.
|
static int |
getWeekDay(long time)
Returns the weekday, from 1-7 where 1 = Sunday.
|
static int |
getYear(long t)
the year for the given time value.
|
static void |
initTimeZone()
Used to read the time tone from System properties.
|
static long |
nextMonth(long date)
Returns the value for date plus 1 month.
|
static long |
nextWeek(long date)
Returns the value for date plus 1 week.
|
static long |
parse_dd_MM_yyyy_HH_mm_ss_GMT_zz_zz(java.lang.String date)
Return a long for the given date date in format
dd MM yyyy HH mm ss +zz zz also values without
timezone or without HH mm ss are parsed! |
static long |
parse_dd_MMM_yyyy_HH_mm_ss_GMT_zz_zz(java.lang.String date)
Return a long for the given date date in format
dd MMM yyyy HH mm ss +zz zz also values without
timezone or without HH mm ss are parsed! |
static long |
parse_yyyy_MM_dd_HH_mm_ss_GMT_zz_zz(java.lang.String date)
Return a long for the given date date in format
yyyy MM dd HH mm ss +zz zz also values without
timezone or without HH mm ss are parsed! |
long |
parse(java.lang.String string)
Parses the date string with the current formatter.
|
static long |
toLong(int[] n)
calculates the long value from the int array - retrieved by calc[].
|
static java.lang.String |
yyyyMMdd(long l)
Return a String for the given date (long) in format yyyyMMdd.
|
static java.lang.String |
yyyyMMddHH(long l)
Return a String for the given date (long) in format yyyyMMddHH.
|
static java.lang.String |
yyyyMMddHHmmss(long l)
Return a String for the given date (long) in format yyyyMMddHHmmss.
|
static java.lang.String |
yyyyMMddHHmmssSSS(long l)
Return a String for the given date (long) in format yyyyMMddHHmmssSSS.
|
public static final int SUNDAY
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
public static final long TIME_PER_DAY
public DateFormat(java.lang.String format)
format
- the format stringpublic DateFormat(java.lang.String format, int tz)
format
- the format stringtz
- timezone offset in secondsDateFormat(String)
public java.lang.String getMask()
public java.lang.String format(long time)
time
- GMT time in milliseconds.public static byte[] ba_dd_MMM_yyyy_HH_mm_ss_zzzz(long l)
dd/MMM/yyyy:HH:mm:ss +zz:zz
.
e.g. 01/Jan/1970:00:00:01 +02:00.
l
- a long representing a date valuepublic static java.lang.String dd_MMM_yyyy_HH_mm_ss_zzzz(long l)
dd/MMM/yyyy:HH:mm:ss +zz:zz
.
e.g. 01/Jan/1970:00:00:01 +02:00.
l
- a long representing a date valuepublic static java.lang.String dd_MMM_yyyy_HH_mm_ss_GMT_zz_zz(long l)
dd/MMM/yyyy:HH:mm:ss GMT+zz:zz
.
e.g. 01/Jan/1970:00:00:01 GMT+02:00.
l
- a long representing a date valuedd/MMM/yyyy:HH:mm:ss GMT+zz:zz
.public static java.lang.String EEE__dd_MMM_yyyy_HH_mm_ss__zzzz(long l)
EEE, dd MMM yyyy HH:mm:ss +zzzz
.
e.g. Thu, 01 Jan 1970 00:00:01 +0200.
l
- a long representing a date valueEEE, dd MMM yyyy HH:mm:ss +zzzz
.public static byte[] ba_EEE__dd_MMM_yyyy_HH_mm_ss_GMT(long l)
EEE, dd MMM yyyy HH:mm:ss GMT
.
e.g. Mon, 01 Jan 1970 00:00:01 GMT.
l
- a long representing a date valueEEE, dd MMM yyyy HH:mm:ss GMT
.public static java.lang.String EEE__dd_MMM_yyyy_HH_mm_ss_GMT(long l)
EEE, dd MMM yyyy HH:mm:ss GMT
.
e.g. Mon, 01 Jan 1970 00:00:01 GMT.
l
- a long representing a date valueEEE, dd MMM yyyy HH:mm:ss GMT
.public static java.lang.String yyyyMMddHHmmss(long l)
l
- a long representing a date valuepublic static java.lang.String yyyyMMddHHmmssSSS(long l)
l
- a long representing a date valuepublic static java.lang.String ddMMyyyyHHmmss(long l)
l
- a long representing a date valuepublic static java.lang.String yyyyMMddHH(long l)
l
- a long representing a date valuepublic static java.lang.String yyyyMMdd(long l)
l
- a long representing a date valuepublic static java.lang.String ddMMyyyy(long l)
l
- a long representing a date valuepublic static int[] calc(long l)
l
- a long representing a date valuepublic static int[] calc(long l, int timeZone)
l
- a long representing a date valuetimeZone
- an explicit time zonepublic static long toLong(int[] n)
n
- the int array as calculated by calc.public static long parse_dd_MMM_yyyy_HH_mm_ss_GMT_zz_zz(java.lang.String date)
dd MMM yyyy HH mm ss +zz zz
also values without
timezone or without HH mm ss are parsed!
e.g. 01/Jan/1970:00:00:01 GMT+02:00 e.g. 01/Jan/1970:00:00:01 e.g. 01/Jan/1970 e.g. 01Jan 1970 00::::::00::::::01 GMT + 02 ---- 00the value of delimiters is ignored!
date
- a date valuedd MMM yyyy HH mm ss +zz zz
public static long parse_dd_MM_yyyy_HH_mm_ss_GMT_zz_zz(java.lang.String date)
dd MM yyyy HH mm ss +zz zz
also values without
timezone or without HH mm ss are parsed!
e.g. 01/01/1970:00:00:01 GMT+02:00 e.g. 01/01/1970:00:00:01 e.g. 01/01/1970 e.g. 0101 1970 00::::::00::::::01 GTM + 02 ---- 00the value of delimiters is ignored!
date
- a date valuedd MMM yyyy HH mm ss +zz zz
public static long parse_yyyy_MM_dd_HH_mm_ss_GMT_zz_zz(java.lang.String date)
yyyy MM dd HH mm ss +zz zz
also values without
timezone or without HH mm ss are parsed!
e.g. 1970/01/01:00:00:01 GMT+02:00 e.g. 1970/01/01:00:00:01 e.g. 1970/01/01 e.g. 19700101123000 e.g. 1970 0101 00::::::00::::::01 GTM + 02 ---- 00the value of delimiters is ignored!
date
- a date valuedd MMM yyyy HH mm ss +zz zz
public static long eastern(int year)
year
- some yearpublic static void initTimeZone()
public static long firstOfWeek(long time)
time
- the time valuepublic static long nextWeek(long date)
date
- a GMT time in milli seconds.public static long nextMonth(long date)
date
- a GMT time in milli secondspublic static long addMonths(long t, int months)
t
- a time valuemonths
- the count of months to addpublic static long firstOfMonth(long date)
date
- a time in milli secondspublic static long firstOfYear(long date)
date
- a time in milli secondspublic static int getWeek(long time)
time
- a time in milli seconds with current timezonepublic static int getDayOfMonth(long date)
date
- as longpublic static int getWeekDay(long time)
time
- a time valuepublic long parse(java.lang.String string)
string
- a date stringpublic static int getMonth(long t)
t
- a time valuepublic static int getYear(long t)
t
- a time valuepublic static long firstOfDay(long t)
t
- a time value