|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.brains2b.util.DateHelper
A function library giving some extra help dealing with dates.
Constructor Summary | |
DateHelper()
|
Method Summary | |
static int |
betweenDate(java.util.Calendar c1,
java.util.Calendar c2,
int field,
boolean round)
calculate the difference between two Calendar s in intervals defined by
field. |
static int |
betweenDate(java.util.Date d1,
java.util.Date d2,
int field,
boolean round)
calculate the difference between two Date s in intervals defined by
field. |
static java.lang.String |
fromDate(java.util.Date dt)
gets a date formatted as String with pattern "dd-MMM-yyyy" |
static java.lang.String |
isoFromDate(java.util.Date d)
|
static java.lang.String |
isoFromDate(java.util.Date d,
boolean includeTime)
|
static java.util.Date |
isoToDate(java.lang.String s)
|
static java.util.Date |
toDate(java.lang.String txt)
returns a Date from a String representing a Date |
static java.util.Date |
toDate(java.lang.String txt,
java.util.Locale locale)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DateHelper()
Method Detail |
public static final java.lang.String fromDate(java.util.Date dt)
dt
- java.util.Date
public static final java.util.Date toDate(java.lang.String txt) throws java.lang.NumberFormatException
ddMMyy
day-month-year
day
can be either 1 or 2 digits, with or without a
leading 0
month
can be either 1 or 2 digits, with or without a
leading 0, a String representing the long name or a short name of the
month. The name of the month must be in the same language at which the VM
it is operating is running in Locale.getDefault() is used to determine
this.year
can be 1 or 2 digits, with or without a leading
0. This is interpreted as a year without a century, so the current
century is added. It can also be four digits and will then be intrepeted
as year including a century.
txt
- String that should be intrepeted as Date
NumberFormatException,
- thrown if at an expected number was not found at the Expected
position.
java.lang.NumberFormatException
public static final java.util.Date toDate(java.lang.String txt, java.util.Locale locale) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static final java.lang.String isoFromDate(java.util.Date d, boolean includeTime)
public static final java.lang.String isoFromDate(java.util.Date d)
public static final java.util.Date isoToDate(java.lang.String s)
public static final int betweenDate(java.util.Date d1, java.util.Date d2, int field, boolean round)
Date
s in intervals defined by
field.
The compare of the calendars follows normal conventions, so if c1 > c2 you will get a negative number. If rounding is on the level below is measured and normal rounding rules apply.
The field value should be one of Calendar.YEAR
,Calendar.MONTH
,Calendar.DATE
d1
- Date one (required)d2
- Date two (required)field
- int, should be in (Calendar.YEAR
|Calendar.MONTH
|Calendar.DATE
)round
- boolean, true if the should difference be rounded according to the normal rounding rules.False will floor the value
Date
s in the defined measurepublic static final int betweenDate(java.util.Calendar c1, java.util.Calendar c2, int field, boolean round)
Calendar
s in intervals defined by
field.
The compare of the calendars follows normal conventions, so if c1 > c2 you will get a negative number. If rounding is on the level below is measured and normal rounding rules apply.
The field value should be one of Calendar.YEAR
,Calendar.MONTH
,Calendar.DATE
c1
- Calendar one (required)c2
- Calendar two (required)field
- int, should be in (Calendar.YEAR
|Calendar.MONTH
|Calendar.DATE
)round
- boolean, true if the should difference be rounded according to the normal rounding rules.False will floor the value
Calendar
s in the defined measure
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |