List of usage examples for java.util Calendar DATE
int DATE
To view the source code for java.util Calendar DATE.
Click Source Link
get
and set
indicating the day of the month. From source file:Main.java
public static Date getTomorrow(Date from) { Calendar c = buildFromDate(from); c.add(Calendar.DATE, 1); // number of days to add return c.getTime(); }
From source file:Main.java
public static Date getYesterday(Date from) { Calendar c = buildFromDate(from); c.add(Calendar.DATE, -1); // number of days to add return c.getTime(); }
From source file:Main.java
public static Date getStartOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);// w w w . ja v a2 s. c o m calendar.set(Calendar.DATE, 1); return calendar.getTime(); }
From source file:Main.java
public static int getCurrentFirstWeekdayOfMoth() { int today = getCurrentDate(); calendar.set(Calendar.DATE, 1); int weekday = calendar.get(Calendar.DAY_OF_WEEK) - 1; calendar.set(Calendar.DATE, today); return weekday; }
From source file:Main.java
public static Date endOfThisMonth() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); calendar.set(Calendar.HOUR, calendar.getActualMaximum(Calendar.HOUR)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMaximum(Calendar.MILLISECOND)); return calendar.getTime(); }
From source file:Main.java
public static Calendar getDateComparedToCurrent(Calendar current, int daysToAdd) { Calendar cal = Calendar.getInstance(); cal.setTime(current.getTime());// www.j a va 2 s. c o m cal.add(Calendar.DATE, daysToAdd); return cal; }
From source file:Main.java
public static Date addDate(Date date, int days) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from www .j ava 2 s . c o m*/ calendar.add(Calendar.DATE, days); return calendar.getTime(); }
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 int getDayNumOfMonth(int y, int m) { Calendar calendar = Calendar.getInstance(); calendar.set(y, m - 1, 1);/* w ww. ja v a2 s .com*/ int dateNumber = calendar.getActualMaximum(Calendar.DATE); return dateNumber; }
From source file:Main.java
private static void prepareCalendarNoSunday(Calendar calendar) { if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.SUNDAY) { calendar.add(Calendar.DATE, 1); }//from w w w . j a v a 2s. c om }