Java String to Timestamp toTimeStamp(String myDate, String pattern, Locale language)

Here you can find the source of toTimeStamp(String myDate, String pattern, Locale language)

Description

to Time Stamp

License

Open Source License

Declaration

public static long toTimeStamp(String myDate, String pattern, Locale language) 

Method Source Code

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

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

public class Main {
    public static long toTimeStamp(String myDate, String pattern, Locale language) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern, language);
        try {/*ww w .j a v a  2s .c o m*/
            Date time = sdf.parse(myDate);
            return time.getTime();
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static long toTimeStamp(String myDate, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            Date time = sdf.parse(myDate);
            return time.getTime();
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. stringToTimestamp(String date)
  2. timestamp(String string)
  3. timeStamp2Date(String timestampString)
  4. timeStampToDate(String timeStamp)
  5. toTimeStamp(String argS)
  6. toTimestamp(String source)
  7. ToTimestamp(String user_time)