public class DateValue
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private java.util.Calendar |
calendar
Internal instance of the Calendar
|
private static java.lang.ThreadLocal<java.text.SimpleDateFormat> |
format
Format used for
DateValue <-> String
conversion. |
Constructor and Description |
---|
DateValue()
Construct an instance for the current date.
|
DateValue(java.util.Date other)
Construct new instance from the instance of the
Date . |
DateValue(DateValue other)
Construct new instance from the other instance of the
DateValue . |
DateValue(int year,
int month,
int day)
Construct an instance for specified date.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.util.Date other)
Compares this instance with instance of
Date for
ordering. |
int |
compareTo(DateValue other)
Compares two instances for ordering.
|
int |
compareTo(java.lang.Object other)
Compare this instance with other object.
|
private void |
enforceTime(java.util.Date input)
This method performs all necessary steps to enforce DateValue instance
to contain only date, without time part.
|
boolean |
equals(java.lang.Object o)
Compares two objects for equality.
|
java.util.Date |
getDate()
Return current value represented as an instance of
Date . |
int |
hashCode()
Return a hash code for the instance.
|
void |
setDate(java.util.Date date)
Set current value using instance of
Date as a source. |
java.lang.String |
toString()
Convert
DateValue instance into String . |
static DateValue |
valueOf(java.lang.String str)
Parse
String like YYYYMMDD and create an instance of
DateValue . |
private static final java.lang.ThreadLocal<java.text.SimpleDateFormat> format
DateValue
<-> String
conversion.private java.util.Calendar calendar
public DateValue()
public DateValue(java.util.Date other)
Date
.other
- An instance which is used as a source of the information.public DateValue(DateValue other)
DateValue
.other
- An instance which is used as a source of the information.public DateValue(int year, int month, int day)
year
- Year value for the new instance.month
- Month value for the new instance.day
- Day of the month value for the new instance.public static DateValue valueOf(java.lang.String str)
String
like YYYYMMDD and create an instance of
DateValue
.str
- Source string.DateValue
instance or null
if
source string does not contain properly formatted date.public int compareTo(java.util.Date other)
Date
for
ordering.other
- The instance of Date
to be compared.0
if dates are equal; a value less than
0
if this instance date is before date of the
passed parameter; a value greater than 0
if this
instance date is after date of the parameter.public int compareTo(DateValue other)
other
- The instance to be compared.0
if instances are equal; a value less than
0
if this instance date is before date of the
instance passed as a parameter; a value greater than
0
if this instance date is after date of the
instance passed as a parameter.public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
other
- The instance of Date
to be compared.0
if dates are equal; a value less than
0
if this instance date is before date of the
passed parameter; a value greater than 0
if this
instance date is after date of the parameter.java.lang.ClassCastException
- if argument is not instance of Date
or
DateValue
.public boolean equals(java.lang.Object o)
Calendar.equals()
or Date.equals()
if possible. Otherwise return
false
.equals
in class java.lang.Object
o
- Object to compare with.true
if instances are equal and
false
otherwise.public java.util.Date getDate()
Date
.java.util.Date
.public int hashCode()
Date.hashCode()
for real computation.hashCode
in class java.lang.Object
public void setDate(java.util.Date date)
Date
as a source.date
- Source instance of Date
to get values from.public java.lang.String toString()
DateValue
instance into String
.toString
in class java.lang.Object
private void enforceTime(java.util.Date input)
input
- Date
instance to set information from.