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 dateToString(String dateString) { Calendar date = Calendar.getInstance(); date.setTimeInMillis((long) Integer.parseInt(dateString) * 1000); return date.get(Calendar.DAY_OF_MONTH) + "/" + String.format("%02d", date.get(Calendar.MONTH) + 1); }
From source file:Main.java
public static Integer getDay(Date date) { if (date == null) return 0; Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww . j a va 2s . co m*/ return cal.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static String getMonthLastDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); return dateFormat.format(calendar.getTime()); }
From source file:Main.java
public static String getFirstDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE)); return new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime()); }
From source file:Main.java
public static String getMonthFirstDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); return dateFormat.format(calendar.getTime()); }
From source file:Main.java
public static Date getDateFromYearMonthDay(int year, int month, int day) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);// w w w . ja va 2 s .c o m cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static int getDayOfMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);// www . java 2 s . co m return c.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static Date getFirstDayOfMonth(Date dateTime) { if (dateTime == null) return dateTime; Calendar calendar = Calendar.getInstance(); calendar.setTime(dateTime);// w ww . j av a 2 s.c om calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime(); }
From source file:Main.java
public static int[] getStartEndDay(Date[] startEnd) { int[] startEndDay = new int[2]; Calendar calendar = Calendar.getInstance(); calendar.setTime(startEnd[0]);/* w w w .j a v a 2s . c o m*/ startEndDay[0] = calendar.get(Calendar.DAY_OF_MONTH); calendar.setTime(startEnd[1]); startEndDay[1] = calendar.get(Calendar.DAY_OF_MONTH); return startEndDay; }
From source file:Main.java
public static int getDayOfWeek(int year, int week) { Calendar calendar = Calendar.getInstance(); calendar.clear();/*from ww w . java 2 s. c o m*/ calendar.set(Calendar.YEAR, year); calendar.set(Calendar.WEEK_OF_YEAR, week); return calendar.get(Calendar.DAY_OF_MONTH); }