List of usage examples for java.util Calendar set
public void set(int field, int value)
From source file:Main.java
private static Calendar clearTimes(Calendar c) { c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0);/*from ww w . j a v a 2s. c om*/ c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c; }
From source file:Main.java
public static Date round2Day(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww. j a v a 2s. c o m*/ cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static Date firstTimeOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w .jav a2 s .c o m*/ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); return cal.getTime(); }
From source file:Main.java
public static Date lastTimeOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//ww w . ja va2 s . c om cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND)); return cal.getTime(); }
From source file:Main.java
private static void setEndOfDayToCalendar(Calendar c) { c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59);//from w w w .j a va 2 s.co m c.set(Calendar.SECOND, 59); }
From source file:Main.java
public static Calendar getLastFriday(Calendar cal, int offset) { int dayofweek; cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + offset); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); dayofweek = cal.get(Calendar.DAY_OF_WEEK); if (dayofweek < Calendar.FRIDAY) cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 7 + Calendar.FRIDAY - dayofweek); else//from w w w .j a v a2s. c om cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) + Calendar.FRIDAY - dayofweek); return cal; }
From source file:Main.java
public static void copyTime(Calendar dest, Calendar src) { dest.set(Calendar.HOUR_OF_DAY, src.get(Calendar.HOUR_OF_DAY)); dest.set(Calendar.MINUTE, src.get(Calendar.MINUTE)); dest.set(Calendar.SECOND, src.get(Calendar.SECOND)); dest.set(Calendar.MILLISECOND, src.get(Calendar.MILLISECOND)); }
From source file:Main.java
public static Calendar clearTime(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:Main.java
public static int getWeekdayOfMonth(Calendar c) { Calendar cal = (Calendar) c.clone(); cal.set(Calendar.DATE, 1); return cal.get(Calendar.DAY_OF_WEEK) - 1; }
From source file:Main.java
public static void clearCalendarSecondWithRear(Calendar cal) { cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); clearCalendarMillisecond(cal);/*from ww w. j a v a2s .c o m*/ }