List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. 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 int getMonthDayNumber(int offset) { Calendar calendar = Calendar.getInstance(); if (offset != 0) calendar.add(Calendar.MONTH, offset); return calendar.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 int getNumberOfDaysInMonth(Date someDayInMonth) { Calendar monthCal = Calendar.getInstance(); monthCal.setTime(someDayInMonth);// w w w . jav a2 s. co m return monthCal.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static java.util.Date getDateEnd(java.util.Date d) { Calendar c = Calendar.getInstance(); c.clear();// w w w. j a v a2 s.c om Calendar co = Calendar.getInstance(); co.setTime(d); c.set(Calendar.DAY_OF_MONTH, co.get(Calendar.DAY_OF_MONTH)); c.set(Calendar.MONTH, co.get(Calendar.MONTH)); c.set(Calendar.YEAR, co.get(Calendar.YEAR)); c.add(Calendar.DAY_OF_MONTH, 1); c.add(Calendar.MILLISECOND, -1); return c.getTime(); }
From source file:Main.java
public static String getRemoteDir() { Calendar calendar = Calendar.getInstance(); String str = calendar.get(Calendar.YEAR) + "_" + (calendar.get(Calendar.MONTH) + 1) + "_" + calendar.get(Calendar.DAY_OF_MONTH); return str;/*from w w w.j av a2s . c om*/ }
From source file:Main.java
public static int getDay(Date date) { return getCalendar(date).get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getUpMonthDays(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*w ww .jav a 2 s. c o m*/ c.add(Calendar.MONTH, -1); return c.getActualMaximum(Calendar.DAY_OF_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
public static int daysBetween(Calendar startDate, Calendar endDate) { Calendar date = (Calendar) startDate.clone(); long daysBetween = 0; while (date.before(endDate)) { date.add(Calendar.DAY_OF_MONTH, 1); daysBetween++;/*from www . ja v a2 s .c om*/ } return (int) (daysBetween / 365.25); }