Java String to Timestamp toTimestamp(String source)

Here you can find the source of toTimestamp(String source)

Description

to Timestamp

License

Open Source License

Declaration

public static Date toTimestamp(String source) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static final String TIMESTAMP_FORMAT = "yyyy/MM/dd HH:mm:ss";

    public static Date toTimestamp(String source) {
        return parse(source, TIMESTAMP_FORMAT);
    }//from   w  w  w .j ava2 s .  c  om

    private static Date parse(String source, String format) {
        SimpleDateFormat parser = new SimpleDateFormat(format);
        try {
            return parser.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. timestamp(String string)
  2. timeStamp2Date(String timestampString)
  3. timeStampToDate(String timeStamp)
  4. toTimeStamp(String argS)
  5. toTimeStamp(String myDate, String pattern, Locale language)
  6. ToTimestamp(String user_time)