Android Date to Milliseconds Convert millisecondOf(int year, int month, int day, int hour, int minute)

Here you can find the source of millisecondOf(int year, int month, int day, int hour, int minute)

Description

millisecond Of

License

Apache License

Declaration

public static long millisecondOf(int year, int month, int day,
            int hour, int minute) 

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.Locale;

public class Main {
    public static long millisecondOf(int year, int month, int day,
            int hour, int minute) {
        try {//from w w w  .  ja  v a2s .  c  om
            SimpleDateFormat format = new SimpleDateFormat(
                    "yyyy-MM-dd mm:ss", Locale.getDefault());
            Date date = format.parse("" + year + "-" + (month + 1) + "-"
                    + day + " " + hour + ":" + minute);
            return date.getTime();
        } catch (ParseException e) {
            android.util.Log.e("DateTimeUtil#millisecondOf", e
                    .getStackTrace().toString());
            throw new RuntimeException(e);
        }
    }

    public static long millisecondOf(int year, int month, int day) {
        return millisecondOf(year, month, day, 0, 0);
    }
}

Related

  1. getTimeInMillis(String date)
  2. millisecondOf(int year, int month, int day)