Java String to Timestamp string2Timestamp(String dateString, String timezone)

Here you can find the source of string2Timestamp(String dateString, String timezone)

Description

string Timestamp

License

Apache License

Declaration

public static long string2Timestamp(String dateString, String timezone) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static long string2Timestamp(String dateString, String timezone) throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if ((timezone != null) && (!timezone.equals(""))) {
            df.setTimeZone(TimeZone.getTimeZone(timezone));
        }/*from  w ww .  j  a v  a 2  s  .  c o  m*/
        Date date1 = df.parse(dateString);
        long temp = date1.getTime();
        return temp;
    }
}

Related

  1. getTimestamp(String timezone, String dateTime, String pattern)
  2. getTimestampFromDateString(String date)
  3. getTimeStampInSecond(String timeStr)
  4. isTimestamp(String str, boolean allowEmpty)
  5. isTimeStampValid(String timestamp)
  6. string2timestamp(String timeString)
  7. stringToTimestamp(String date)
  8. timestamp(String string)
  9. timeStamp2Date(String timestampString)