List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:Main.java
private static long getTimeInMillis() { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 21); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar.getTimeInMillis(); }
From source file:Main.java
public static String parseDay(long dateDay) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(dateDay); Date date = calendar.getTime(); return formarDay.format(date); }
From source file:Main.java
public static String getDateString(long millitm) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(millitm); return (setZeroPad(cal.get(Calendar.YEAR)) + "/" + setZeroPad(cal.get(Calendar.MONTH)) + "/" + setZeroPad(cal.get(Calendar.DATE)) + " " + setZeroPad(cal.get(Calendar.HOUR_OF_DAY)) + ":" + setZeroPad(cal.get(Calendar.MINUTE)) + ":" + setZeroPad(cal.get(Calendar.SECOND))); }
From source file:Main.java
public static String getCurTime(String format) { long now = System.currentTimeMillis(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(now); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(calendar.getTime()); }
From source file:Main.java
public static String transformMillisToDate(long millis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", // Locale.CHINA); SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm", Locale.CHINA); return format.format(calendar.getTime()); }
From source file:Main.java
public static int getMinute(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); return c.get(Calendar.MINUTE); }
From source file:Main.java
public static int getHourOfDay(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); return c.get(Calendar.HOUR_OF_DAY); }
From source file:Main.java
public static String createCCPFileName() { Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); int y = c.get(Calendar.YEAR); int m = c.get(Calendar.MONTH); int d = c.get(Calendar.DAY_OF_MONTH); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int second = c.get(Calendar.SECOND); return y + "-" + m + "-" + d + "-" + hour + "-" + minute + "-" + second; }
From source file:Main.java
public static long getDayInUTC(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); cal.set(Calendar.HOUR, 0);//from w w w. j av a2 s .co m cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.setTimeZone(TimeZone.getTimeZone("UTC")); return cal.getTimeInMillis(); }
From source file:Main.java
/** * Returns the date// w w w. jav a 2s . com * @param timestamp This is the long milliseconds date since epoch * @return Returns a date object */ public static Date getDate(Long timestamp) { if (timestamp == null) return null; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timestamp); return cal.getTime(); }