|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mmbase.util.DateSupport
Some routines to support dates better
The problem that generally occurs is with timezones. Therefore, we have made the following structure:
| Constructor Summary | |
DateSupport()
|
|
| Method Summary | |
static java.lang.String |
colontime(java.lang.String time)
Puts a colon between a time of RFC-1223 format |
static long |
convertDateToLong(java.lang.String date)
Convert a string (like "12:42:15 1/2/97") to milliseconds from 1970 The timezone used is 'GMT' |
static long |
convertDateToLongWithTimeZone(java.lang.String date,
int hour,
int minutes)
Convert date to long with timezone-offset example : convertDateToLongWithTimeZone ( "14:12:56 3/5/1998", 3, 30 ) will convert the date to milliseconds passes from 1970 untill this date with -3:30 timezone |
static long |
currentTimeMillis()
Return the current time in milliseconds (for the current-timezone!!) |
static java.util.Date |
Date(int year,
int week,
int day)
Return a date, based on a year, a week and the day of that week For instance: 1999, 40, 4 = The 4th day of the 40th week of 1999 |
static java.lang.String |
date2date(int time)
Return a string for a given date |
static java.lang.String |
date2day(int time)
Return a string for a given date |
static java.lang.String |
date2string(int time)
Return a string for a given date |
static int |
dayInYear(java.util.Date d)
Return the number of days that have elapsed from the beginning of the year to the given date |
static int |
daysInMonth(int year,
int month)
Return the number of days in the month in a specified year. |
static int |
getDayInt(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the day in the month as an integer |
static long |
getMilliOffset()
Return the time-difference between our timezone and GMT |
static java.lang.String |
getMonth(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the month |
static java.lang.String |
getMonthDay(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the day in the month |
static int |
getMonthInt(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the month as an integer |
static java.lang.String |
getTime(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string |
static java.lang.String |
getTimeSec(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string |
static java.lang.String |
getTimeSecLen(int val)
Takes an integer representing the number of seconds from 00:00:00 and returns the time as a string |
static int |
getWeekDayInt(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the day in the week as an integer |
static java.lang.String |
getYear(int val)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the year |
static void |
main(java.lang.String[] args)
Main method used for testing purposes |
static java.lang.String |
makedbmdate(java.util.Date da)
Create date strings in the form yyyy-mm-dd for a given Date object This format is used in several database (dbm's) |
static long |
milliDate(int year,
int week)
Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week. |
static java.util.Calendar |
parseDate(java.util.Calendar cal,
java.lang.String date)
Parse a string containing a date and put it in a calendar |
static int |
parsedate(java.lang.String sDate)
Returns the number of seconds from 1-Jan-1970 to a given date |
static java.util.Calendar |
parseDateRev(java.util.Calendar cal,
java.lang.String date)
Parse a string containing a date and put it in a calendar, the string is in reversed order |
static int |
parsedatetime(java.lang.String wh)
Returns the number of seconds from 1-Jan-1970 00:00:00 to a given time |
static java.util.Date |
parsedbmdate(java.lang.String wh)
Parse date strings in the form yyyy-mm-dd This format is used in several database (dbm's) |
static int |
parsetime(java.lang.String wh)
Returns the number of seconds from 00:00:00 to a given time |
static int |
secondInYear(java.util.Date d)
Return the number of seconds that have elapsed from the beginning of the year to the given date |
static int |
weekInYear(java.util.Date d)
Return the number of weeks that have elapsed from the beginning of the year to the given date |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DateSupport()
| Method Detail |
public static int daysInMonth(int year,
int month)
year - The year valid values 0..100 where 0 is y2k 2000 untill 89 => 2089 and 90 being the year 1990month - The month where 0 is januaripublic static int secondInYear(java.util.Date d)
d - The date
daysInMonth(int, int),
dayInYear(java.util.Date),
weekInYear(java.util.Date)public static int dayInYear(java.util.Date d)
d - The date
daysInMonth(int, int),
secondInYear(java.util.Date),
weekInYear(java.util.Date)public static int weekInYear(java.util.Date d)
d - The date
daysInMonth(int, int),
secondInYear(java.util.Date),
dayInYear(java.util.Date)
public static long milliDate(int year,
int week)
year - The yearweek - The number of the week
public static java.util.Date Date(int year,
int week,
int day)
year - The yearweek - The weekday - The number of the day in the week
public static java.lang.String makedbmdate(java.util.Date da)
da - The date input
parsedbmdate(java.lang.String)public static java.util.Date parsedbmdate(java.lang.String wh)
wh - The string representing the date in 'yyyy-mm-dd' format
makedbmdate(java.util.Date)public static java.lang.String colontime(java.lang.String time)
time - A string in RFC-1223 format
public static int parsedate(java.lang.String sDate)
sDate - String in the form 'yyyyMMdd'
parsetime(java.lang.String),
parsedatetime(java.lang.String)public static int parsetime(java.lang.String wh)
wh - Time in the form 'hhmmss'
parsedate(java.lang.String),
parsedatetime(java.lang.String)public static int parsedatetime(java.lang.String wh)
wh - Date in the form 'yyyymmddhhmmss'
parsedate(java.lang.String),
parsetime(java.lang.String)public static java.lang.String getTime(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static java.lang.String getTimeSec(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static java.lang.String getTimeSecLen(int val)
val - Number of seconds from 00:00:00
getTime(int),
getTimeSec(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static java.lang.String getMonthDay(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static java.lang.String getMonth(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static java.lang.String getYear(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getMonthInt(int),
getWeekDayInt(int),
getDayInt(int)public static int getMonthInt(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getWeekDayInt(int),
getDayInt(int)public static int getWeekDayInt(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getDayInt(int)public static int getDayInt(int val)
val - Number of seconds from 1-Jan-1970 00:00:00
getTime(int),
getTimeSec(int),
getTimeSecLen(int),
getMonthDay(int),
getMonth(int),
getYear(int),
getMonthInt(int),
getWeekDayInt(int)public static long getMilliOffset()
public static long currentTimeMillis()
public static long convertDateToLong(java.lang.String date)
date - String which contains the date and time in the format "hour:minutes:sec day/month/year"
public static long convertDateToLongWithTimeZone(java.lang.String date,
int hour,
int minutes)
date - Date to be converted in format: hour:minute:second day/month/yearhour - Hour-part of the timezone-offset (int)minutes - Minutes-part of the timezone-offset (int)
public static java.util.Calendar parseDate(java.util.Calendar cal,
java.lang.String date)
cal - Calander object that is used for storing the parsed datedate - String in the form: hour:minute:second day/month/year
parseDateRev
public static java.util.Calendar parseDateRev(java.util.Calendar cal,
java.lang.String date)
cal - Calander object that is used for storing the parsed datedate - String in the form: year/month/day hour:minute:second
parseDatepublic static java.lang.String date2string(int time)
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
date2day(int),
date2date(int)public static java.lang.String date2day(int time)
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
date2string(int),
date2date(int)public static java.lang.String date2date(int time)
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
date2string(int),
date2day(int)public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||