Java String to Timestamp ToTimestamp(String user_time)

Here you can find the source of ToTimestamp(String user_time)

Description

To Timestamp

License

Open Source License

Declaration

public static String ToTimestamp(String user_time) 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String ToTimestamp(String user_time) {
        String re_time = null;/*from w ww .  ja  v  a 2  s . c o m*/
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date d;
        try {
            d = sdf.parse(user_time);
            long l = d.getTime();
            String str = String.valueOf(l);
            re_time = str.substring(0, 10);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return re_time;
    }
}

Related

  1. timeStamp2Date(String timestampString)
  2. timeStampToDate(String timeStamp)
  3. toTimeStamp(String argS)
  4. toTimeStamp(String myDate, String pattern, Locale language)
  5. toTimestamp(String source)