|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.DateUtil
public class DateUtil
Utility methods that will make it easier to handle date values. Especially, dates must be cloned whenver they are returned to or passed from client applications.
Field Summary | |
---|---|
private static SimpleDateFormat |
DATE_FORMAT
|
private static SimpleDateFormat |
TIMESTAMP_FORMAT
|
Constructor Summary | |
---|---|
DateUtil()
|
Method Summary | |
---|---|
static Date |
copy(Date value)
Get a copy of the date. |
static String |
formatDate(Date d)
Formats a date in yyyy-MM-dd format. |
static String |
formatTimestamp(Date d)
Formats a timestamp in yyyy-MM-dd HH:mm:ss format. |
static Date |
parseString(String value)
Parses a string to create a Date without time. |
static Date |
parseTimestamp(String value)
Parses a string to create a Date including time. |
static Date |
setNotNullDate(Date value,
String name)
Make a copy of a Date object. |
static Date |
setNullableDate(Date value,
String name)
Make a copy of a Date object. |
static Date |
truncate(Date value)
Truncate the given date so that only the date part remains. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final SimpleDateFormat DATE_FORMAT
private static final SimpleDateFormat TIMESTAMP_FORMAT
Constructor Detail |
---|
public DateUtil()
Method Detail |
---|
public static Date setNullableDate(Date value, String name)
Date
object. Null values are allowed.
value
- The date to checkname
- The name of the attribute to use if an exception is thrown
public static Date setNotNullDate(Date value, String name) throws InvalidUseOfNullException
Date
object. Null values are not allowed.
value
- The date to check. Can not be null.name
- The name of the attribute to use if an exception is thrown
InvalidUseOfNullException
- If the value parameter is null.public static Date copy(Date value)
value
- Date value to copy
public static Date truncate(Date value)
value
- The date to truncate, can be null
public static Date parseString(String value) throws InvalidDataException
Date
without time. This method supports
date in yyyy-MM-dd format or as long timevalues.
value
- the String
to be parsed
Date
object
DateFormatException
- if value
isn't a valid date.
InvalidDataException
public static String formatDate(Date d)
d
- The date to format.
public static Date parseTimestamp(String value) throws InvalidDataException
Date
including time. This method
supports date in yyyy-MM-dd HH:mm:ss format or as long timevalues.
value
- the String
to be parsed
Date
object
DateFormatException
- if value
isn't a valid timestamp
InvalidDataException
public static String formatTimestamp(Date d)
d
- The date to format.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |