List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static int getDaysOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); return days;/*from www. ja va2 s .c om*/ }
From source file:Main.java
public static String getDateString(long millitm) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(millitm);// w w w. ja va 2 s . co m 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 long getTimeMillisAt(int hour, int minute) { Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, hour); today.set(Calendar.MINUTE, minute); return today.getTimeInMillis(); }
From source file:Main.java
public static int getMonthOfDays(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); return calendar.getActualMaximum(Calendar.DATE); }
From source file:Main.java
public static int getDayOfYear() { return Calendar.getInstance().get(Calendar.DAY_OF_YEAR); }
From source file:Main.java
public static Calendar getCalendarClearMinuteByNow() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:Main.java
public static Date getNextDate(int days) { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_WEEK, days); return c.getTime(); }
From source file:Main.java
public static long getBeginOfCurrentDateInMillis() { Calendar calendar = Calendar.getInstance(); calendar.clear(Calendar.HOUR); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); return calendar.getTimeInMillis(); }
From source file:Main.java
public static boolean isTaday(Long time) { Calendar calendar_cur = Calendar.getInstance(); Calendar calendar_old = Calendar.getInstance(); calendar_old.setTimeInMillis(time);//from w w w . ja v a 2 s .c om int day_cur = calendar_cur.get(Calendar.DAY_OF_YEAR); int day_old = calendar_old.get(Calendar.DAY_OF_YEAR); if (day_cur == day_old) { return true; } else { return false; } }
From source file:Main.java
public static long getUTCTime() { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("gmt")); return cal.getTimeInMillis(); }