List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:Main.java
public static String convertLongToString(long time, String format) { String myDate = null;/*from w w w .j a v a 2 s.co m*/ SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern(format); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); Date date = calendar.getTime(); myDate = sdf.format(date); return myDate; }
From source file:Main.java
public static Calendar getCalendar(long milliseconds) { Calendar calendar = getCalendar(); calendar.setTimeInMillis(milliseconds); return calendar; }
From source file:Main.java
public static String getFormatTime4(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); String strFileName = getFormatTime1(c); return strFileName; }
From source file:Main.java
public static boolean isBrithdayAvable(Long d) { if (d == null) { return false; }//from w w w . j ava2s . c o m boolean back = false; Calendar c = Calendar.getInstance(); c.setTimeInMillis(d.longValue()); Calendar current = Calendar.getInstance(); if (c.get(Calendar.YEAR) > 1801 && c.before(current) && c.get(Calendar.YEAR) <= current.get(Calendar.YEAR)) { return true; } return back; }
From source file:Main.java
/** * yyyyMMddHHmmss//from w w w . ja v a 2 s. co m */ public static String getFormatTime2(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); String strFileName = getFormatTime3(c); return strFileName; }
From source file:Main.java
public static int getDaylightSavingsTimeOffset(long timeMs) { int dstOffset = 5; // default not daylight savings time Calendar c = Calendar.getInstance(); c.setTimeInMillis(timeMs); int day = c.get(Calendar.DATE); int month = c.get(Calendar.MONTH); if ((month > DST_START_MONTH && month < DST_END_MONTH) || (month == DST_START_MONTH && day >= DST_START_DAY) || (month == DST_END_MONTH && day <= DST_END_DAY)) { dstOffset = 4;//from w ww .j a va 2 s . c om } return dstOffset; }
From source file:Main.java
public static String getTimeStampDDMMYYYY(long l) { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(l); return makeTimeString(cal.get(Calendar.DAY_OF_MONTH), 2) + "." + makeTimeString(cal.get(Calendar.MONTH) + 1, 2) + "." + makeTimeString(cal.get(Calendar.YEAR), 4); }
From source file:Main.java
public static String getTime() { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(System.currentTimeMillis()); return cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND); }
From source file:Main.java
public static Calendar getCalendar(final long millis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); return calendar; }
From source file:Main.java
private static long calcTimeBettwenZeroAndNow() { Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.setTimeInMillis(System.currentTimeMillis()); int currentHour = calendar.get(calendar.HOUR); calendar.add(Calendar.HOUR, 24 - currentHour); return calendar.getTimeInMillis(); }