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 String formatNoaaForCalendar(Calendar c) { return "" + c.get(Calendar.YEAR) + "-" + String.format("%02d", (c.get(Calendar.MONTH) + 1)) + "-" + String.format("%02d", c.get(Calendar.DATE)); }
From source file:Main.java
public static Date getDateAfter(Date d, int day) { Calendar now = Calendar.getInstance(); now.setTime(d);/*from w ww.jav a2 s . c o m*/ now.set(Calendar.DATE, now.get(Calendar.DATE) + day); return now.getTime(); }
From source file:Main.java
public static int getCurrentMouth() { Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int mouth = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DATE); int currentIndex = (year - 1970) * 12 + mouth; return currentIndex; }
From source file:Main.java
public static long getEndOfCurrentWeek() { Calendar calendar = getCalendarWithTime(getStartOfCurrentWeek()); calendar.add(Calendar.DATE, 6); return calendar.getTimeInMillis(); }
From source file:Main.java
public static int getDaysByYearMonth(int year, int month) { Calendar a = Calendar.getInstance(); a.set(Calendar.YEAR, year);/*from ww w. j a v a 2 s . c om*/ a.set(Calendar.MONTH, month - 1); a.set(Calendar.DATE, 1); a.roll(Calendar.DATE, -1); return a.get(Calendar.DATE); }
From source file:Main.java
/** * ????date???n???????/*from w w w .jav a 2 s . c om*/ */ public static Date getDateAfter(Date date, int n) { Calendar now = Calendar.getInstance(); now.setTime(date); now.set(Calendar.DATE, now.get(Calendar.DATE) + n); return now.getTime(); }
From source file:Main.java
public static String getDateDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US) + " " + cal.get(Calendar.DATE) + ", " + cal.get(Calendar.YEAR); }
From source file:Main.java
public static String getTomorrow() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); Date date = cal.getTime();/*w w w .j a va 2 s .c om*/ SimpleDateFormat sf = new SimpleDateFormat(DATE_FORMAT); return sf.format(date); }
From source file:Main.java
public static String getShortDateDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.DATE); }
From source file:Main.java
public static int[] getYMD(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w w w . j a va 2 s.co m return new int[] { cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DATE) }; }