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 getUpMonthDays(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from www. j av a 2s. c o m*/ c.add(Calendar.MONTH, -1); return c.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static long getEndOfCurrentYear() { Calendar calendar = getCurrentCalendar(); calendar.set(Calendar.MONTH, 11); return calendar.getTimeInMillis(); }
From source file:Main.java
public static int getNextMonthDays(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w w w.ja v a 2s .co m c.add(Calendar.MONTH, 1); return c.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getWeek(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK) - 1; }
From source file:Main.java
public static String getCurrentDateString() { Calendar date = Calendar.getInstance(); int day = date.get(Calendar.DATE); int month = (date.get(Calendar.MONTH)) + 1; int year = date.get(Calendar.YEAR); String dateString = month + "-" + day + "-" + year; return dateString; }
From source file:Main.java
public static boolean isCurrentDate(Calendar comparedDate) { Calendar cal = Calendar.getInstance(); int[] comparedElements = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH }; for (int elem : comparedElements) { if (cal.get(elem) != comparedDate.get(elem)) { return false; }// w w w .j av a2s. c o m } return true; }
From source file:Main.java
public static String getMySQLDateFormat() { //Membuat string tanggal sekarang Calendar now = Calendar.getInstance(); int month = now.get(Calendar.MONTH) + 1; int day = now.get(Calendar.DAY_OF_MONTH); int year = now.get(Calendar.YEAR); return year + "-" + month + "-" + day; }
From source file:Main.java
public static long getStartOfCurrentYear() { Calendar calendar = getCurrentCalendar(); calendar.set(Calendar.MONTH, 0); return calendar.getTimeInMillis(); }
From source file:Main.java
public static void copyTo(Calendar from, Calendar to) { int year = from.get(Calendar.YEAR); int month = from.get(Calendar.MONTH); int day = from.get(Calendar.DAY_OF_MONTH); to.set(year, month, day);/*from w ww . j a v a 2 s .c om*/ to.getTimeInMillis(); }
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); }