org.mmbase.util
Class DateSupport

java.lang.Object
  extended by org.mmbase.util.DateSupport

Deprecated. use Calendar and java.util.DateFormat

public class DateSupport
extends Object

Some routines to support dates better

The problem that generally occurs is with timezones. Therefore, we have made the following structure:

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).

Version:
$Id: DateSupport.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Rico Jansen, Johannes Verelst

Field Summary
(package private) static boolean dooffset
          Deprecated. Whether to sue the offset.
(package private) static int offset
          Deprecated. The offset for date conversions for the current zone, in seconds
 
Constructor Summary
DateSupport()
          Deprecated.  
 
Method Summary
static String colontime(String time)
          Deprecated. Puts a colon between a time of RFC-1223 format
static long convertDateToLong(String date)
          Deprecated. Convert a string (like "12:42:15 1/2/97") to milliseconds from 1970 The timezone used is 'GMT'
static long currentTimeMillis()
          Deprecated. Return the current time in milliseconds (for the current-timezone!!)
static Date Date(int year, int week, int day)
          Deprecated. 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 String date2date(int time)
          Deprecated. Return a string for a given date
static String date2day(int time)
          Deprecated. Return a string for a given date
static String date2string(int time)
          Deprecated. Return a string for a given date
static int dayInYear(Date d)
          Deprecated. 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)
          Deprecated. Return the number of days in the month in a specified year.
static int getDayInt(int val)
          Deprecated. 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()
          Deprecated. Return the time-difference between our timezone and GMT
static String getMonth(int val)
          Deprecated. Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the month
static String getMonthDay(int val)
          Deprecated. 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)
          Deprecated. Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the month as an integer
static String getTime(int val)
          Deprecated. Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string
static String getTimeSec(int val)
          Deprecated. Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string
static String getTimeSecLen(int val)
          Deprecated. Takes an integer representing the number of seconds from 00:00:00 and returns the time as a string
static int getWeekDayInt(int val)
          Deprecated. 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 String getYear(int val)
          Deprecated. Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the year
static void main(String[] args)
          Deprecated. Main method used for testing purposes
static String makedbmdate(Date da)
          Deprecated. 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)
          Deprecated. Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week.
static Calendar parseDate(Calendar cal, String date)
          Deprecated. Parse a string containing a date and put it in a calendar
static int parsedate(String sDate)
          Deprecated. Returns the number of seconds from 1-Jan-1970 to a given date
static Calendar parseDateRev(Calendar cal, String date)
          Deprecated. Parse a string containing a date and put it in a calendar, the string is in reversed order
static int parsedatetime(String wh)
          Deprecated. Returns the number of seconds from 1-Jan-1970 00:00:00 to a given time
static Date parsedbmdate(String wh)
          Deprecated. Parse date strings in the form yyyy-mm-dd
This format is used in several database (dbm's)
static int parsetime(String wh)
          Deprecated. Returns the number of seconds from 00:00:00 to a given time
static int secondInYear(Date d)
          Deprecated. Return the number of seconds that have elapsed from the beginning of the year to the given date
static int weekInYear(Date d)
          Deprecated. 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
 

Field Detail

offset

static int offset
Deprecated. 
The offset for date conversions for the current zone, in seconds


dooffset

static boolean dooffset
Deprecated. 
Whether to sue the offset. Set to true when initialization of this class succeeds.

Constructor Detail

DateSupport

public DateSupport()
Deprecated. 
Method Detail

daysInMonth

public static int daysInMonth(int year,
                              int month)
Deprecated. 
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
month - The month where 0 is januari

secondInYear

public static int secondInYear(Date d)
Deprecated. 
Return the number of seconds that have elapsed from the beginning of the year to the given date

Parameters:
d - The date
Returns:
The number of secods from January 1 to the given date
See Also:
daysInMonth(int, int), dayInYear(java.util.Date), weekInYear(java.util.Date)

dayInYear

public static int dayInYear(Date d)
Deprecated. 
Return the number of days that have elapsed from the beginning of the year to the given date

Parameters:
d - The date
Returns:
The number of days from January 1 to the given date
See Also:
daysInMonth(int, int), secondInYear(java.util.Date), weekInYear(java.util.Date)

weekInYear

public static int weekInYear(Date d)
Deprecated. 
Return the number of weeks that have elapsed from the beginning of the year to the given date

Parameters:
d - The date
Returns:
The number of weeks from January 1 to the given date
See Also:
daysInMonth(int, int), secondInYear(java.util.Date), dayInYear(java.util.Date)

milliDate

public static long milliDate(int year,
                             int week)
Deprecated. 
Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week.

Parameters:
year - The year
week - The number of the week
Returns:
The number of milliseconds between 1-Jan-1970 and the begin of the given week.

Date

public static Date Date(int year,
                        int week,
                        int day)
Deprecated. 
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
week - The week
day - The number of the day in the week
Returns:
A date-object for the given date

makedbmdate

public static String makedbmdate(Date da)
Deprecated. 
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
Returns:
A string in the form yyyy-mm-dd
See Also:
parsedbmdate(java.lang.String)

parsedbmdate

public static Date parsedbmdate(String wh)
Deprecated. 
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
Returns:
A Date object for the given date
See Also:
makedbmdate(java.util.Date)

colontime

public static String colontime(String time)
Deprecated. 
Puts a colon between a time of RFC-1223 format

Parameters:
time - A string in RFC-1223 format
Returns:
A string with an extra colon

parsedate

public static int parsedate(String sDate)
Deprecated. 
Returns the number of seconds from 1-Jan-1970 to a given date

Parameters:
sDate - String in the form 'yyyyMMdd'
Returns:
Number of seconds from 1-Jan-1970
See Also:
parsetime(java.lang.String), parsedatetime(java.lang.String)

parsetime

public static int parsetime(String wh)
Deprecated. 
Returns the number of seconds from 00:00:00 to a given time

Parameters:
wh - Time in the form 'hhmmss'
Returns:
Number of seconds from 00:00:00 to the given time
See Also:
parsedate(java.lang.String), parsedatetime(java.lang.String)

parsedatetime

public static int parsedatetime(String wh)
Deprecated. 
Returns the number of seconds from 1-Jan-1970 00:00:00 to a given time

Parameters:
wh - Date in the form 'yyyymmddhhmmss'
Returns:
Number of seconds from 1-Jan-1970 00:00:00 to the given time
See Also:
parsedate(java.lang.String), parsetime(java.lang.String)

getTime

public static String getTime(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
String in the form 'hhmm' for the given time
See Also:
getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getYear(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getTimeSec

public static String getTimeSec(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
String in the form 'hhmmss' for the given time
See Also:
getTime(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getYear(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getTimeSecLen

public static String getTimeSecLen(int val)
Deprecated. 
Takes an integer representing the number of seconds from 00:00:00 and returns the time as a string

Parameters:
val - Number of seconds from 00:00:00
Returns:
String in the form 'hhmmss' for the given time
See Also:
getTime(int), getTimeSec(int), getMonthDay(int), getMonth(int), getYear(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getMonthDay

public static String getMonthDay(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the day in the month

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
String containing the day of the month (1 to 31)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonth(int), getYear(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getMonth

public static String getMonth(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the month

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
String containing the number of the month (1 to 12)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getYear(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getYear

public static String getYear(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the year

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
String containing the year (1900 to ....)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getMonthInt(int), getWeekDayInt(int), getDayInt(int)

getMonthInt

public static int getMonthInt(int val)
Deprecated. 
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the month as an integer

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
Integer containing the value of the month (1 to 12)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getYear(int), getWeekDayInt(int), getDayInt(int)

getWeekDayInt

public static int getWeekDayInt(int val)
Deprecated. 
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

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
Integer containing the number of the day in the week (0 to 6)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getYear(int), getMonthInt(int), getDayInt(int)

getDayInt

public static int getDayInt(int val)
Deprecated. 
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

Parameters:
val - Number of seconds from 1-Jan-1970 00:00:00
Returns:
Integer containing the number of the day in the month (1 to 31)
See Also:
getTime(int), getTimeSec(int), getTimeSecLen(int), getMonthDay(int), getMonth(int), getYear(int), getMonthInt(int), getWeekDayInt(int)

getMilliOffset

public static long getMilliOffset()
Deprecated. 
Return the time-difference between our timezone and GMT

Returns:
Integer containing the number of milliseconds representing the time-difference between us and GMT

currentTimeMillis

public static long currentTimeMillis()
Deprecated. 
Return the current time in milliseconds (for the current-timezone!!)

Returns:
Integer containing the number of milliseconds representing the current time

convertDateToLong

public static long convertDateToLong(String date)
Deprecated. 
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"
Returns:
the elapsed milliseconds since 1970 from this date

parseDate

public static Calendar parseDate(Calendar cal,
                                 String date)
Deprecated. 
Parse a string containing a date and put it in a calendar

Parameters:
cal - Calander object that is used for storing the parsed date
date - String in the form: hour:minute:second day/month/year
Returns:
Calander object representing the parsed date
See Also:
parseDateRev

parseDateRev

public static Calendar parseDateRev(Calendar cal,
                                    String date)
Deprecated. 
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
date - String in the form: year/month/day hour:minute:second
Returns:
Calander object representing the parsed date
See Also:
parseDate

date2string

public static String date2string(int time)
Deprecated. 
Return a string for a given date

Parameters:
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
Returns:
String in the form 'hhmmss day/month/year'
See Also:
date2day(int), date2date(int)

date2day

public static String date2day(int time)
Deprecated. 
Return a string for a given date

Parameters:
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
Returns:
String in the form 'year-month-day'
See Also:
date2string(int), date2date(int)

date2date

public static String date2date(int time)
Deprecated. 
Return a string for a given date

Parameters:
time - Integer representing the time in seconds since 1-Jan-1970 00:00:00
Returns:
String in the form 'year-month-day hhmmss'
See Also:
date2string(int), date2day(int)

main

public static void main(String[] args)
Deprecated. 
Main method used for testing purposes

Parameters:
args - Array of arguments


MMBase 2.0-SNAPSHOT - null