Here you can find the source of convertDateToLong(int year, int month, int day, int hour, int minute, int second)
Parameter | Description |
---|---|
year | a parameter |
month | a parameter |
day | a parameter |
hour | a parameter |
minute | a parameter |
second | a parameter |
public static long convertDateToLong(int year, int month, int day, int hour, int minute, int second)
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**//from w ww. ja va 2s .c o m * convert a given date to long representation * * @param year * @param month * @param day * @param hour * @param minute * @param second * @return the long representation of the given time */ public static long convertDateToLong(int year, int month, int day, int hour, int minute, int second) { Date d = getDate(year, month, day, hour, minute, second); return d.getTime(); } /** * get Date object with given values * * @param year * @param month * @param day * @param hour * @param minute * @param second * @return */ public static Date getDate(int year, int month, int day, int hour, int minute, int second) { Calendar c = new GregorianCalendar(); c.set(year, month - 1, day); c.set(Calendar.HOUR, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, second); c.set(Calendar.AM_PM, Calendar.AM); return c.getTime(); } }