org.h2.util
Class DateTimeIso8601Utils

java.lang.Object
  extended by org.h2.util.DateTimeIso8601Utils

public class DateTimeIso8601Utils
extends java.lang.Object

Calculate day of week, week of year and year according to the ISO 8601 specification. See also http://en.wikipedia.org/wiki/ISO_8601

The specification defines that the week starts at Monday. The first week of the year is defined as the week which contains at least 4 days of the new year. Therefore if January 1st is on Thursday (or earlier) it belongs to the first week, otherwise to the last week of the previous year. Hence January 4th always belongs to the first week while the December 28th always belongs to the last week. The year of a date reflects to this corresponding week definition.


Constructor Summary
DateTimeIso8601Utils()
           
 
Method Summary
static int getIsoDayOfWeek(java.util.Date date)
          Return the day of week.
static int getIsoWeek(java.util.Date date)
          Returns the week of the year.
static int getIsoYear(java.util.Date date)
          Returns the year according to the ISO week definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeIso8601Utils

public DateTimeIso8601Utils()
Method Detail

getIsoDayOfWeek

public static int getIsoDayOfWeek(java.util.Date date)
Return the day of week. Week starts at Monday.

Parameters:
date - the date object which day of week should be calculated
Returns:
the day of the week, Monday as 1 to Sunday as 7

getIsoWeek

public static int getIsoWeek(java.util.Date date)
Returns the week of the year. The spec defines the first week of the year as this week which contains at least 4 days. The week starts at Monday. Therefore December 29th - 31th could belong to the next year and January 1st - 3th could belong to the previous year.

Parameters:
date - the date object which week of year should be calculated
Returns:
the week of the year

getIsoYear

public static int getIsoYear(java.util.Date date)
Returns the year according to the ISO week definition.

Parameters:
date - the date object which year should be calculated
Returns:
the year