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

TimestampString2Timestamp(String s, String fmt)
String Timestamp
Timestamp ts = new Timestamp(new Date().getTime());
try {
    SimpleDateFormat df = new SimpleDateFormat(fmt);
    ts = new Timestamp(df.parse(s).getTime());
    return ts;
} catch (Exception ex) {
return ts;
...
Timestampstring2Timestamp(String strDateTime, String pattern)
string Timestamp
if (strDateTime == null || strDateTime.equals("")) {
    throw new java.lang.IllegalArgumentException("Date Time Null Illegal");
if (pattern == null || pattern.equals("")) {
    pattern = PATTERN_STANDARD;
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date date = null;
...
java.sql.TimestampString2Timestamp(String strInputDate)
String Timestamp
String strDate = strInputDate;
int i, nYear, nMonth, nDay;
String strSub = null;
i = strDate.indexOf("/");
if (i < 0) {
    return createTimestamp();
strSub = strDate.substring(0, i);
...
Timestampstring2Timestamp(String value)
string Timestamp
if (value == null && !"".equals(value.trim())) {
    return null;
Timestamp ts = new Timestamp(System.currentTimeMillis());
ts = Timestamp.valueOf(value);
return ts;
TimestampstringToTimestamp()
string To Timestamp
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(new Date());
return Timestamp.valueOf(time);
TimestampstringToTimestamp(final String dateString)
string To Timestamp
Timestamp tms;
try {
    tms = Timestamp.valueOf(dateString);
} catch (IllegalArgumentException expected) {
    try {
        tms = new Timestamp(new Long(dateString));
    } catch (Exception e) {
        tms = new Timestamp(stringToDate(dateString).getTime());
...
java.sql.TimestampstringToTimestamp(String aS_Timestamp, String aS_Format, Timestamp aTs_ValidStart, Timestamp aTs_ValidEnd)
Converts string to java.sql.Timestamp using format string
SimpleDateFormat l_SimpleDateFormat;
java.sql.Timestamp l_Timestamp;
java.util.Date l_Date = null;
if (aS_Timestamp == null || aS_Format == null) {
    return null;
l_SimpleDateFormat = new SimpleDateFormat(aS_Format);
try {
...
TimestampstringToTimestamp(String date, String formatStr)
string To Timestamp
SimpleDateFormat format = new SimpleDateFormat(formatStr);
format.setLenient(false);
try {
    Timestamp ts = new Timestamp(format.parse(date).getTime());
    return ts;
} catch (ParseException e) {
    e.printStackTrace();
    return null;
...
TimestampstringToTimeStamp(String dateTimeString, String dateTimeFormat, TimeZone tz, Locale locale)
Localized String to Timestamp conversion.
DateFormat dateFormat = toDateTimeFormat(dateTimeFormat, tz, locale);
Date parsedDate = dateFormat.parse(dateTimeString);
return new Timestamp(parsedDate.getTime());
TimestampstringToTimestamp(String marcTimestamp)
Convert string in format "yyyyMMddhhmmss.S" (as in the MARC records) to java.sql.Timestamp
Timestamp timestamp;
Date d = new SimpleDateFormat("yyyyMMddHHmmss.S").parse(marcTimestamp);
timestamp = new Timestamp(d.getTime());
timestamp.setNanos(Integer.parseInt(marcTimestamp.substring(marcTimestamp.length() - 1)));
return timestamp;