Android Calendar Get getTimeByStr(String str)

Here you can find the source of getTimeByStr(String str)

Description

get Time By Str

License

Open Source License

Declaration

public static long getTimeByStr(String str) 

Method Source Code

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

public class Main {
    private static final String PARSE_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static long getTimeByStr(String str) {
        SimpleDateFormat sdf = new SimpleDateFormat(PARSE_DATE_FORMAT);
        Date date;/* w w w.j  a v  a2s  .c om*/
        try {
            date = sdf.parse(str);
            return date.getTime();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return System.currentTimeMillis();
        }

    }
}

Related

  1. getMinute()
  2. getMinute(Calendar c)
  3. getMonth()
  4. getMonth(Calendar c)
  5. getSecond(Calendar c)
  6. getTimeMillis()
  7. getWeek(final Calendar calendar)
  8. getWeek(final Long date)
  9. getYear()