List of usage examples for java.util Calendar set
public void set(int field, int value)
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 Calendar newInitializedCalendar() { Calendar newitem = Calendar.getInstance(); newitem.set(Calendar.HOUR, 0); newitem.set(Calendar.MINUTE, newitem.getMinimum(Calendar.MINUTE)); newitem.set(Calendar.SECOND, newitem.getMinimum(Calendar.SECOND)); newitem.set(Calendar.MILLISECOND, newitem.getMinimum(Calendar.MILLISECOND)); return newitem; }
From source file:Main.java
public static int getWeek(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK) - 1; }
From source file:Main.java
private static Calendar getTodayAutoPushTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static String getMonthFirstDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); return dateFormat.format(calendar.getTime()); }
From source file:Main.java
public static String getDayOfWeekString(int day) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, day); SimpleDateFormat format = new SimpleDateFormat("EEE", Locale.US); return format.format(calendar.getTime()); }
From source file:Main.java
public static Calendar getDate(Calendar calendar) { Calendar cal = (Calendar) calendar.clone(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from w w w. jav a2 s . c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; }
From source file:Main.java
public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);//from w w w . j ava 2s . co m cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static String getMonthOfYearString(int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month - 1); SimpleDateFormat format = new SimpleDateFormat("MMM", Locale.US); return format.format(calendar.getTime()); }
From source file:Main.java
public static Calendar getCalendarAtMidnight(int relativeDayToToday) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.add(Calendar.DAY_OF_YEAR, relativeDayToToday); return calendar; }