List of usage examples for java.util Calendar set
public void set(int field, int value)
From source file:Main.java
static private Calendar getCalendarAlarmTime(int hour, int minute) { Calendar alarmTime = Calendar.getInstance(); alarmTime.set(Calendar.HOUR_OF_DAY, hour); alarmTime.set(Calendar.MINUTE, minute); alarmTime.set(Calendar.SECOND, 0); return alarmTime; }
From source file:Main.java
public static Calendar GetLastMonthRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Calendar GetYesterdayRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
/** * the first day of month/* w w w . j a v a 2s . co m*/ * @param year * @param month * @return week position */ public static int getDayOfWeekInMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DATE, 1); return calendar.get(Calendar.DAY_OF_WEEK); }
From source file:Main.java
public static Calendar GetThisMonthLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Date beginOfThisMonth() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); calendar.set(Calendar.HOUR, calendar.getActualMinimum(Calendar.HOUR)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMinimum(Calendar.MILLISECOND)); return calendar.getTime(); }
From source file:Main.java
public static String getLastDayOfThisMonth() { String str = ""; Calendar lastDate = Calendar.getInstance(); lastDate.set(Calendar.DATE, 1);// lastDate.add(Calendar.MONTH, 1);// lastDate.add(Calendar.DATE, -1);// str = sdf.format(lastDate.getTime()); return str;/*from w w w. ja v a 2 s . co m*/ }
From source file:Main.java
public static String getFirstDayOfThisMonth() { String str = ""; Calendar lastDate = Calendar.getInstance(); lastDate.set(Calendar.DATE, 1);// // lastDate.add(Calendar.MONTH,-1);// // lastDate.add(Calendar.DATE,-1);// str = sdf.format(lastDate.getTime()); return str;/*w w w. j av a 2 s.co m*/ }
From source file:Main.java
public static String[] getWeekDays() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); String[] weekDays = new String[7]; for (int i = 0; i < 7; i++) { weekDays[i] = WEEK_DAYS_FORMAT.format(calendar.getTime()); calendar.add(Calendar.DATE, 1); }//from w w w .j av a 2 s .c o m return weekDays; }
From source file:Main.java
public static Calendar GetThisYearLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }