org.ephman.utils
Class TimestampConverter
java.lang.Object
|
+--org.ephman.utils.TimestampConverter
- public class TimestampConverter
- extends java.lang.Object
Field Summary |
protected static java.lang.String |
DEFAULT_FORMAT
|
protected static java.text.SimpleDateFormat |
formatter
|
Method Summary |
static java.lang.String |
format(java.sql.Timestamp time)
routine to format a timestamp in the default way
'yyyy-MM-dd HH:mm:ss' |
static java.lang.String |
format(java.sql.Timestamp time,
java.lang.String timeFormat)
routine to format a timestamp using the 'timeFormat' |
static java.sql.Timestamp |
parse(java.lang.String date)
routine to parse a string in the default way
'yyyy-MM-dd HH:mm:ss' to timestamp |
static java.sql.Timestamp |
parse(java.lang.String date,
java.lang.String timeFormat)
routine to parse a string using the passed
timeFormat to timestamp |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
formatter
protected static java.text.SimpleDateFormat formatter
DEFAULT_FORMAT
protected static java.lang.String DEFAULT_FORMAT
TimestampConverter
public TimestampConverter()
format
public static java.lang.String format(java.sql.Timestamp time)
- routine to format a timestamp in the default way
'yyyy-MM-dd HH:mm:ss'
- Parameters:
time
- the timestamp to turn into String
format
public static java.lang.String format(java.sql.Timestamp time,
java.lang.String timeFormat)
- routine to format a timestamp using the 'timeFormat'
- Parameters:
time
- the timestamp to turn into StringtimeFormat
- a format string @link SimpleDateFormat
- Returns:
- String that is properly formatted
parse
public static java.sql.Timestamp parse(java.lang.String date)
throws java.text.ParseException
- routine to parse a string in the default way
'yyyy-MM-dd HH:mm:ss' to timestamp
- Parameters:
date
- a string which should be turned into a timestamp
- Returns:
- Timestamp representing the string that was passed
- Throws:
java.text.ParseException
- if the string is not parseable
parse
public static java.sql.Timestamp parse(java.lang.String date,
java.lang.String timeFormat)
throws java.text.ParseException
- routine to parse a string using the passed
timeFormat to timestamp
- Parameters:
timeFormat
- the format to use when parsing the given datedate
- a string which should be turned into a timestamp
- Returns:
- Timestamp representing the string that was passed
- Throws:
java.text.ParseException
- if the string is not parseable