List of usage examples for java.util Calendar MONTH
int MONTH
To view the source code for java.util Calendar MONTH.
Click Source Link
get
and set
indicating the month. From source file:Main.java
public static boolean isSameDate(Calendar calendar1, Calendar calendar2) { if (calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH)) { return true; } else {//w ww. j a v a 2s.c o m return false; } }
From source file:Main.java
public static Date addMonth(Date date, int months) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from ww w .ja v a 2 s .co m*/ calendar.add(Calendar.MONTH, months); return calendar.getTime(); }
From source file:Main.java
@Deprecated public static int getMonthOfMonth(int y, int m) { Calendar calendar = Calendar.getInstance(); calendar.set(y, m - 1, 1);/*from w w w .ja v a 2 s.com*/ int month = calendar.get(Calendar.MONTH); return month + 1; }
From source file:Main.java
public static String getCurrentDateString() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR) + "-" + String.format("%02d", (calendar.get(Calendar.MONTH) + 1)) + "-" + String.format("%02d", calendar.get(Calendar.DATE)); }
From source file:Main.java
public static Date nextMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(getFirstDate(date)); calendar.add(Calendar.MONTH, 1); return calendar.getTime(); }
From source file:Main.java
public static int getMonth() { long ts = System.currentTimeMillis(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(ts);//from www. ja va2 s.co m return calendar.get(Calendar.MONTH) + 1; }
From source file:Main.java
public static String getActualSemesterTag() { final int month = GregorianCalendar.getInstance().get(Calendar.MONTH); if (month > Calendar.FEBRUARY && month < Calendar.SEPTEMBER) return "S"; return "W"; }
From source file:Main.java
public static int[] getYMD(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* w w w. ja v a2 s . c om*/ return new int[] { cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DATE) }; }
From source file:Main.java
private static Calendar add(long time, int val, int field) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time);// ww w . ja va 2 s . c o m if (field == 666) { c.add(Calendar.MONTH, val * 3); } else { c.add(field, val); } return c; }
From source file:Main.java
public static String getMonthOfYearString(int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month - 1); SimpleDateFormat format = new SimpleDateFormat("MMM", Locale.US); return format.format(calendar.getTime()); }