| |
|
| java.lang.Object org.mmbase.util.DateSupport
DateSupport | public class DateSupport (Code) | | Some routines to support dates better
The problem that generally occurs is with timezones. Therefore, we have made the following structure:
- If a date is stored in a database, it is in GMT
- If a date is displayed, it happens in the timezone of the machine that is calling.
This means that some timezone conversions have to be made.
We assume nothing about timezones, we just read the value specified by the system (Timezone.getDefault() call).
author: Rico Jansen author: Johannes Verelst version: $Id: DateSupport.java,v 1.29 2008/02/03 17:33:57 nklasens Exp $ |
Field Summary | |
static boolean | dooffset Whether to sue the offset. | static int | offset |
dooffset | static boolean dooffset(Code) | | Whether to sue the offset.
Set to true when initialization of this class succeeds.
|
offset | static int offset(Code) | | The offset for date conversions for the current zone, in seconds
|
Date | public static Date Date(int year, int week, int day)(Code) | | 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
Parameters: year - The year Parameters: week - The week Parameters: day - The number of the day in the week A date-object for the given date |
colontime | public static String colontime(String time)(Code) | | Puts a colon between a time of RFC-1223 format
Parameters: time - A string in RFC-1223 format A string with an extra colon |
convertDateToLong | public static long convertDateToLong(String date)(Code) | | Convert a string (like "12:42:15 1/2/97") to milliseconds from 1970
The timezone used is 'GMT'
Parameters: date - String which contains the date and time in the format "hour:minutes:sec day/month/year" the elapsed milliseconds since 1970 from this date |
currentTimeMillis | public static long currentTimeMillis()(Code) | | Return the current time in milliseconds (for the current-timezone!!)
Integer containing the number of milliseconds representing the current time |
date2date | public static String date2date(int time)(Code) | | Return a string for a given date
Parameters: time - Integer representing the time in seconds since 1-Jan-1970 00:00:00 String in the form 'year-month-day hhmmss' See Also: DateSupport.date2string See Also: DateSupport.date2day |
date2string | public static String date2string(int time)(Code) | | Return a string for a given date
Parameters: time - Integer representing the time in seconds since 1-Jan-1970 00:00:00 String in the form 'hhmmss day/month/year' See Also: DateSupport.date2day See Also: DateSupport.date2date |
daysInMonth | public static int daysInMonth(int year, int month)(Code) | | Return the number of days in the month in a specified year.
Leap years have to be taken into account
Parameters: year - The year valid values 0..100 where 0 is y2k 2000 untill 89 => 2089 and 90 being the year 1990 Parameters: month - The month where 0 is januari |
getMilliOffset | public static long getMilliOffset()(Code) | | Return the time-difference between our timezone and GMT
Integer containing the number of milliseconds representing the time-difference between us and GMT |
main | public static void main(String args)(Code) | | Main method used for testing purposes
Parameters: args - Array of arguments |
makedbmdate | public static String makedbmdate(Date da)(Code) | | Create date strings in the form yyyy-mm-dd for a given Date object
This format is used in several database (dbm's)
Parameters: da - The date input A string in the form yyyy-mm-dd See Also: DateSupport.parsedbmdate |
milliDate | public static long milliDate(int year, int week)(Code) | | Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week.
Parameters: year - The year Parameters: week - The number of the week The number of milliseconds between 1-Jan-1970 and the begin of the given week. |
parseDate | public static Calendar parseDate(Calendar cal, String date)(Code) | | Parse a string containing a date and put it in a calendar
Parameters: cal - Calander object that is used for storing the parsed date Parameters: date - String in the form: hour:minute:second day/month/year Calander object representing the parsed date See Also: DateSupport See Also: parseDateRev |
parseDateRev | public static Calendar parseDateRev(Calendar cal, String date)(Code) | | Parse a string containing a date and put it in a calendar, the string is in reversed order
Parameters: cal - Calander object that is used for storing the parsed date Parameters: date - String in the form: year/month/day hour:minute:second Calander object representing the parsed date See Also: DateSupport See Also: parseDate |
parsedatetime | public static int parsedatetime(String wh)(Code) | | Returns the number of seconds from 1-Jan-1970 00:00:00 to a given time
Parameters: wh - Date in the form 'yyyymmddhhmmss' Number of seconds from 1-Jan-1970 00:00:00 to the given time See Also: DateSupport.parsedate See Also: DateSupport.parsetime |
parsedbmdate | public static Date parsedbmdate(String wh)(Code) | | Parse date strings in the form yyyy-mm-dd
This format is used in several database (dbm's)
Parameters: wh - The string representing the date in 'yyyy-mm-dd' format A Date object for the given date See Also: DateSupport.makedbmdate |
|
|
|