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 int getMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from w w w. j a va2 s. c o m*/ return calendar.get(Calendar.MONTH); }
From source file:Main.java
public static int getWeekOfFirstDay(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK); }
From source file:Main.java
private static long beginningOfTheDay(Calendar time) { Calendar copy = (Calendar) time.clone(); copy.clear();/*from w ww .j a v a 2s. c o m*/ copy.set(time.get(Calendar.YEAR), time.get(Calendar.MONTH), time.get(Calendar.DAY_OF_MONTH)); return copy.getTimeInMillis(); }
From source file:Main.java
public static int getMonthOfYear(Date time) { Calendar calendar = Calendar.getInstance(); calendar.setTime(time);/*from w w w . j a va2 s. c o m*/ return calendar.get(Calendar.MONTH); }
From source file:Main.java
public static Date addMouth(Date date, int step) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from www . j a va 2 s. co m calendar.add(Calendar.MONTH, step); return calendar.getTime(); }
From source file:Main.java
public static long getTimesMonthMorning() { Calendar cal = Calendar.getInstance(); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); return cal.getTimeInMillis(); }
From source file:Main.java
public static boolean isInSameDay(Calendar calendar1, Calendar calendar2) { return 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); }
From source file:Main.java
/** * Set the last day of the month//from ww w. ja v a 2 s. c o m * @param c Calendar */ public static void setLastDayMonth(Calendar c) { c.add(Calendar.MONTH, 1); c.add(Calendar.DAY_OF_YEAR, -1); }
From source file:Main.java
private static Calendar getCurrentExpDate() { Calendar now = Calendar.getInstance(); now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 0, 0, 0); return now;/*from w w w . j av a 2 s . co m*/ }
From source file:Main.java
public static String getTodayDateString() { Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) + 1; int day = now.get(Calendar.DAY_OF_MONTH); String monthStr = String.valueOf(month); String dayStr = String.valueOf(day); if (month < 10) { monthStr = "0" + dayStr; }// ww w. j a v a 2s. com if (day < 10) { dayStr = "0" + dayStr; } String nowDate = year + "-" + monthStr + "-" + dayStr; return nowDate; }