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

DateparseTimestamp(String s)
parse Timestamp
if (s == null)
    return null;
return dfDateTime_mmddyyyy.parse(s);
TimestampparseTimestamp(String sDate, String sFormat)
parse Timestamp
java.text.SimpleDateFormat formatter = null;
java.util.Date utildate = null;
formatter = new java.text.SimpleDateFormat(sFormat);
utildate = formatter.parse(sDate);
java.sql.Timestamp tsdate = new java.sql.Timestamp(utildate.getTime());
return tsdate;
TimestampparseTimestamp(String src, String pattern)
parse Timestamp
Date date = parseDate(src, pattern);
return new Timestamp(date.getTime());
TimestampparseTimestamp(String strDate)
parse Timestamp
try {
    Timestamp result = Timestamp.valueOf(strDate);
    return result;
} catch (Exception pe) {
    return null;
booleanparseTimestamp(String time)
Parse the time
StringBuilder dateFormat = new StringBuilder("yyyy-MM-dd'T'HH:mm:ss"); 
int fromIndex = time.lastIndexOf(':');
if (time.indexOf('+', fromIndex) > 0 || time.indexOf('-', fromIndex) > 0) {
    dateFormat.append('Z');
try {
    Date date = new SimpleDateFormat(dateFormat.toString()).parse(time);
    long ms = date.getTime();
...
DateparseTimestamp(String timestamp)
Parses a timestamp string in YYYY-MM-dd HH:mm:ss GMT format.
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
    return df.parse(timestamp);
} catch (ParseException e) {
    e.printStackTrace();
    return new Date();
CalendarparseTimeStamp(String timeStamp)
parse Time Stamp
return parseDateTime(timeStamp, FORMAT_TIMESTAMP);
DateparseTimestamp(String timestamp)
parse Timestamp
TimeZone tz = TimeZone.getTimeZone("America/Chicago");
DateFormat sdf = new SimpleDateFormat("yyyyMMdd h:m:s");
sdf.setTimeZone(tz);
return sdf.parse(timestamp);
DateparseTimestamp(String timestamp)
parse Timestamp
int length = timestamp.length();
DateFormat format = null;
if (length == LONG_FORMAT_LENGTH) {
    format = new SimpleDateFormat(DATE_TIME_FORMAT);
} else if (length == SHORT_FORMAT_LENGTH) {
    format = new SimpleDateFormat(DATE_FORMAT);
} else {
    throw new ParseException("timestamp has unexpected format: '" + timestamp + "'", 0);
...
longparseTimeStamp(String timeStamp)
parse Time Stamp
SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
Date date;
try {
    date = format.parse(timeStamp);
} catch (ParseException e) {
    SimpleDateFormat optFormat = new SimpleDateFormat("yy-MM-dd HH:mm");
    date = optFormat.parse(timeStamp);
return date.getTime();