Java Timestamp Parse String2Timestamp(String s, String fmt)

Here you can find the source of String2Timestamp(String s, String fmt)

Description

String Timestamp

License

Open Source License

Declaration

public static Timestamp String2Timestamp(String s, String fmt) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Timestamp String2Timestamp(String s, String fmt) {
        Timestamp ts = new Timestamp(new Date().getTime());
        try {//from   w ww .  j a  va  2 s .  c o m
            SimpleDateFormat df = new SimpleDateFormat(fmt);
            ts = new Timestamp(df.parse(s).getTime());
            return ts;
        } catch (Exception ex) {
        }
        return ts;
    }
}

Related

  1. parseTimestampDirectory(final String stamp)
  2. parseTimestampToString(Timestamp stamp, String dateFormat)
  3. parseToDate(String timestamp, String pattern)
  4. str2Timestamp(String str)
  5. String2Timestamp(String date)
  6. string2Timestamp(String strDateTime, String pattern)
  7. String2Timestamp(String strInputDate)
  8. string2Timestamp(String value)
  9. stringToTimestamp()