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 String getCurrentTime() { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); String time = year + "-" + month + "-" + day; return time;//from w w w .j av a 2 s . c o m }
From source file:Main.java
public static int getMonth() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.MONTH); return year;/*from w w w . j a va2 s . c om*/ }
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 int getPreviousMonth() { current.add(Calendar.MONTH, -1); return current.get(Calendar.MONTH); }
From source file:Main.java
public static int getdataCount(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); int count = cal.getActualMaximum(Calendar.DATE); return count; }
From source file:Main.java
public static int getMonthOfMonth(int y, int m) { Calendar cal = Calendar.getInstance(); cal.set(y, m - 1, 1);/*from w w w .j av a 2 s .c o m*/ int dateOfMonth = cal.get(Calendar.MONTH); return dateOfMonth + 1; }
From source file:Main.java
public static Calendar todaysCalendar() { Calendar now = Calendar.getInstance(); return createNewCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, now.get(Calendar.DAY_OF_MONTH)); }
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 String getFirstDayOfLastMonth() { Calendar c = Calendar.getInstance(); int month = c.get(Calendar.MONTH); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH)); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); }
From source file:Main.java
public static int getMonthFromDate(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w w w . j a va 2s . c om return c.get(Calendar.MONTH); }