Java Utililty Methods Timestamp Parse

List of utility methods to do Timestamp Parse

Description

The list of methods to do Timestamp Parse are organized into topic(s).

Method

java.sql.TimestampparseTimestamp(final String s)
parse Timestamp
final String[] components = s.split(" ");
if (components.length != 2) {
    throw new IllegalArgumentException("Invalid escape format: " + s);
final String[] timeComponents = components[1].split("\\.");
if (timeComponents.length != 2) {
    throw new IllegalArgumentException("Invalid escape format: " + s);
} else if (timeComponents[1].length() != 9) {
...
TimestampparseTimeStamp(final String... key)
parse Time Stamp
final String dateStr = key[0] + "-" + key[1] + "-" + key[2] + " " + key[3] + ":" + key[4] + ":" + key[5];
return new Timestamp(format.parse(dateStr).getTime());
StringparseTimestamp(Long time, String pattern)
parse Timestamp
String dateStr = "";
if (time != 0) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    Date date = new Date(time);
    dateStr = sdf.format(date);
return dateStr;
longparseTimestamp(Object o)
parse Timestamp
String timestamp = o.toString();
SimpleDateFormat sdf;
if (timestamp.length() == 8) {
    sdf = new SimpleDateFormat("HH:mm:ss");
} else if (timestamp.length() == 5) {
    sdf = new SimpleDateFormat("HH:mm");
} else {
    return (0L);
...
LongparseTimestamp(String d)
parse Timestamp
if (d == null) {
    return null;
try {
    return s_dateFormat.parse(d).getTime();
} catch (ParseException e) {
    throw new RuntimeException(e);
DateparseTimestamp(String date)
parse Timestamp
return getTimetampFormat().parse(date);
java.sql.TimestampparseTimestamp(String dateStr, String format)
parse Timestamp
java.util.Date date = parseDate(dateStr, format);
if (date != null) {
    long t = date.getTime();
    return new java.sql.Timestamp(t);
} else
    return null;
TimestampparseTimestamp(String dateString)
Convert date string to timestamp.
Timestamp timestamp = null;
try {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
    Date parsedDate = dateFormat.parse(dateString);
    timestamp = new Timestamp(parsedDate.getTime());
} catch (Exception e) {
    e.printStackTrace();
return timestamp;
java.sql.TimestampparseTimestamp(String pattern, String dateTime)
parse Timestamp
return new java.sql.Timestamp(parseDate(pattern, dateTime).getTime());
TimestampparseTimestamp(String s)
parse Timestamp
Timestamp value;
if (s.indexOf(':') > 0) {
    value = Timestamp.valueOf(s);
} else if (s.indexOf('.') >= 0) {
    value = new Timestamp((long) ((double) (Double.parseDouble(s) * 1000)));
} else {
    value = new Timestamp(Long.parseLong(s) * 1000);
return value;