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 Calendar nextMonday() { Calendar date = new GregorianCalendar(); while (date.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { date.add(Calendar.DATE, 1); }//from w ww . j a va 2s . c om date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); return date; }
From source file:Main.java
public static int getdataCount(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); int count = cal.getActualMaximum(Calendar.DATE); return count; }
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 Date getDifferenceDaysDate(long times, int diffDay) { Calendar now = Calendar.getInstance(); Date d = new Date(); d.setTime(times);//from w w w.jav a 2 s .c om now.setTime(d); now.set(Calendar.DATE, now.get(Calendar.DATE) + diffDay); return now.getTime(); }
From source file:Main.java
public static int getDay(int y, int m, int d) { if (m < 0 || m > 11) return -1; Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, y);/*from w ww . j a va2 s.c o m*/ c.set(Calendar.MONTH, m); c.set(Calendar.DATE, d); return c.get(Calendar.DAY_OF_WEEK) - 1; }
From source file:Main.java
/** * Get First Date of month// ww w . j a v a2s . c o m */ public static Date getFirstDateOfMonth(int month, int year) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, 1); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); return calendar.getTime(); }
From source file:Main.java
public static String dateformat(String format, Date date, int afterDay) { Calendar ca = Calendar.getInstance(); ca.setTime(date);/*from w ww .j av a 2s.c o m*/ if (afterDay != 0) ca.add(Calendar.DATE, afterDay); SimpleDateFormat df = new SimpleDateFormat(format); return df.format(ca.getTime()); }
From source file:Main.java
public static String getDateStr(int index) { SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); java.util.Calendar calendar = new java.util.GregorianCalendar(); calendar.add(Calendar.DATE, index); String retDate = ""; try {/*from w w w.j a v a2 s .com*/ retDate = df.format(calendar.getTime()); } catch (Exception ex) { ex.printStackTrace(); } return retDate; }
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;/* www. ja v a 2 s . c o 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. ja v a 2 s. c o m }