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 getLastDayOfYear() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); return calendar.getTime(); }
From source file:Main.java
public static int getDayNum(int index) { java.util.Calendar calendar = new java.util.GregorianCalendar(); calendar.add(Calendar.DATE, index);// int dWeek = calendar.get(Calendar.DAY_OF_WEEK); int realDay = (dWeek - 1) == 0 ? 7 : (dWeek - 1); return realDay; }
From source file:Main.java
public static String getYesterdayData() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); String yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime()); return yesterday; }
From source file:Main.java
public static Date changeDate(int days) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, days); return calendar.getTime(); }
From source file:Main.java
public static Calendar tomorrow() { Calendar date = new GregorianCalendar(); date.add(Calendar.DATE, 1); 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 w w w . j a va 2 s . c om }
From source file:Main.java
public static String getFormatDate(int step) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, step); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); String str = sf.format(cal.getTime()); return str;/*from www .j a v a2 s. c o m*/ }
From source file:Main.java
public static Calendar getMonday(Calendar calendar) { while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { calendar.add(Calendar.DATE, -1); }//from w w w . j a v a 2 s . co m return calendar; }
From source file:Main.java
private static String setDate(int day, Locale locale) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, +day); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); if (df instanceof SimpleDateFormat) { SimpleDateFormat sdf = (SimpleDateFormat) df; // To show Locale specific short date expression with full year String pattern = sdf.toPattern().replaceAll("y+", "yyyy"); sdf.applyPattern(pattern);/*from w w w. java 2 s .c o m*/ return sdf.format(cal.getTime()); } String formattedDate = df.format(cal.getTime()); return formattedDate; }
From source file:Main.java
public static Date getDateBefore(Date d, int day) { Calendar now = Calendar.getInstance(); now.setTime(d);/*w ww . j a va2 s .c om*/ now.set(Calendar.DATE, now.get(Calendar.DATE) - day); return now.getTime(); }
From source file:Main.java
public static String getYestoryDate() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -1); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String yestoday = sdf.format(calendar.getTime()); return yestoday; }