org.clazzes.util.datetime
Class GlobalDate
java.lang.Object
org.clazzes.util.datetime.GlobalDate
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<GlobalDate>
public class GlobalDate
- extends java.lang.Object
- implements java.lang.Comparable<GlobalDate>, java.io.Serializable
A class to store a simple Gregorian Date (i.e. year, month, day) as 8 digit integer (yyyymmdd) in a database.
The purpose is to protect the e.g. dates of birth, historical dates etc.
against any layer's pseudo intelligence regarding time zones and so on.
- Author:
- lech
- See Also:
- Serialized Form
Field Summary |
protected int |
day
|
protected int |
month
|
protected int |
year
|
protected java.lang.Integer |
yyyymmdd
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
year
protected int year
month
protected int month
day
protected int day
yyyymmdd
protected java.lang.Integer yyyymmdd
GlobalDate
public GlobalDate()
GlobalDate
public GlobalDate(int year,
int month,
int day)
- Parameters:
year
- 1-9999month
- 1-12day
- 1-31
GlobalDate
public GlobalDate(java.util.Date date)
GlobalDate
public GlobalDate(java.util.Calendar calendar)
GlobalDate
public GlobalDate(UtcTimestamp utcTimestamp)
GlobalDate
public GlobalDate(long utcMillis)
GlobalDate
public GlobalDate(int yyyymmdd)
ymd2yyyymmdd
protected void ymd2yyyymmdd()
yyyymmdd2ymd
protected void yyyymmdd2ymd()
setDate
public void setDate(int year,
int month,
int day)
- Parameters:
year
- 1-9999month
- 1-12day
- 1-31
toDate
public java.util.Date toDate()
toCalendar
public java.util.Calendar toCalendar()
toUtcTimestamp
public UtcTimestamp toUtcTimestamp()
toMillis
public long toMillis()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
setDate
public void setDate(java.util.Date date)
setDate
public void setDate(java.util.Calendar calendar)
setDate
public void setDate(UtcTimestamp utcTimestamp)
setDate
public void setDate(long utcMillis)
getYyyymmdd
public java.lang.Integer getYyyymmdd()
- Returns:
- the yyyymmdd
setYyyymmdd
public void setYyyymmdd(java.lang.Integer yyyymmdd)
- Parameters:
yyyymmdd
- the yyyymmdd to set
getYear
public int getYear()
- Returns:
- the year, 1-9999
setYear
public void setYear(int year)
- Parameters:
year
- the year to set, 1-9999
getMonth
public int getMonth()
- Returns:
- the month, 1-12
setMonth
public void setMonth(int month)
- Parameters:
month
- the month to set, 1-12
getDay
public int getDay()
- Returns:
- the day, 1-31
setDay
public void setDay(int day)
- Parameters:
day
- the day to set, 1-31
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in class java.lang.Object
compareTo
public int compareTo(GlobalDate o)
- Specified by:
compareTo
in interface java.lang.Comparable<GlobalDate>
before
public boolean before(GlobalDate other)
after
public boolean after(GlobalDate other)
Copyright © 2009. All Rights Reserved.