Java Millisecond Format strToDateMillisTimestamp(String dateStr, String formatStr)

Here you can find the source of strToDateMillisTimestamp(String dateStr, String formatStr)

Description

str To Date Millis Timestamp

License

Open Source License

Declaration

public static long strToDateMillisTimestamp(String dateStr, String formatStr) 

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 long strToDateMillisTimestamp(String dateStr, String formatStr) {
        Date date = strToDate(dateStr, formatStr);
        return date != null ? date.getTime() : 0;
    }//from   www.  jav  a2  s .c o m

    public static Date strToDate(String dateStr, String formatStr) {
        Date date = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat(formatStr);
            date = format.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. prettyPrintMillis(long millis)
  2. prettyPrintTime(long millis)
  3. printDate(long millis)
  4. reverseFormattedDateWithMilliseconds()
  5. stringToTimestampInMilliseconds(String s, DateFormat formatter)
  6. timeFormat(final long milliseconds)
  7. timeMillisToString(long timeMillis, String dateFormat)