com.devexperts.util
Class DayUtil

java.lang.Object
  extended by com.devexperts.util.DayUtil

public class DayUtil
extends Object

A collection of static utility methods for manipulation of int day id, that is the number of days since Unix epoch of January 1, 1970.


Method Summary
static int getDayIdByYearMonthDay(int yyyymmdd)
          Returns day identifier for specified yyyymmdd integer in Gregorian calendar.
static int getDayIdByYearMonthDay(int year, int month, int day)
          Returns day identifier for specified year, month and day in Gregorian calendar.
static int getYearMonthDayByDayId(int dayId)
          Returns yyyymmdd integer in Gregorian calendar for a specified day identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDayIdByYearMonthDay

public static int getDayIdByYearMonthDay(int year,
                                         int month,
                                         int day)
Returns day identifier for specified year, month and day in Gregorian calendar. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. Month must be between 1 and 12 inclusive. Year and day might take arbitrary values assuming proleptic Gregorian calendar. The value returned by this method for an arbitrary day value always satisfies the following equality: getDayIdByYearMonthDay(year, month, day) == getDayIdByYearMonthDay(year, month, 0) + day

Throws:
IllegalArgumentException - when month is less than 1 or more than 12.

getDayIdByYearMonthDay

public static int getDayIdByYearMonthDay(int yyyymmdd)
Returns day identifier for specified yyyymmdd integer in Gregorian calendar. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. The yyyymmdd integer is equal to yearSign * (abs(year) * 10000 + month * 100 + day), where year, month, and day are in Gregorian calendar, month is between 1 and 12 inclusive, and day is counted from 1.

Throws:
IllegalArgumentException - when month is less than 1 or more than 12.
See Also:
getDayIdByYearMonthDay(int year, int month, int day)

getYearMonthDayByDayId

public static int getYearMonthDayByDayId(int dayId)
Returns yyyymmdd integer in Gregorian calendar for a specified day identifier. The day identifier is defined as the number of days since Unix epoch of January 1, 1970. The result is equal to yearSign * (abs(year) * 10000 + month * 100 + day), where year, month, and day are in Gregorian calendar, month is between 1 and 12 inclusive, and day is counted from 1.



Copyright © 2013 Devexperts. All Rights Reserved.