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 Calendar buildCalendarInstance(final int year, final int month, final int dayOfMonth) { final Calendar c = Calendar.getInstance(); c.clear();//from w w w . j a v a2s . co m c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); return c; }
From source file:Main.java
public static boolean isSameDate(Calendar calendar1, Calendar calendar2) { if (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)) { return true; } else {//from w w w . j a va 2s . com return false; } }
From source file:Main.java
@NonNull public static String getTime() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); }
From source file:Main.java
public static Calendar setAsToday(Calendar aoCalendar) { Calendar loCalendar = Calendar.getInstance(); aoCalendar.set(Calendar.YEAR, loCalendar.get(Calendar.YEAR)); aoCalendar.set(Calendar.MONTH, loCalendar.get(Calendar.MONTH)); aoCalendar.set(Calendar.DAY_OF_MONTH, loCalendar.get(Calendar.DAY_OF_MONTH)); return aoCalendar; }
From source file:Main.java
public static long getStartOfMonthMs(int year, int month) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, date.getActualMinimum(Calendar.DAY_OF_MONTH)); date.set(Calendar.HOUR_OF_DAY, date.getActualMinimum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMinimum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMinimum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMinimum(Calendar.MILLISECOND)); return date.getTimeInMillis(); }
From source file:Main.java
public static String toYYYYMMDD(Calendar source) { if (source == null) { return "Can't toYYYYMMDDHHMMSS source null"; }/*from w w w. j ava2 s . c o m*/ int YYYY = source.get(Calendar.YEAR); int MM = source.get(Calendar.MONTH); int DD = source.get(Calendar.DAY_OF_MONTH); return YYYY + "-" + MM + "-" + DD; }
From source file:Main.java
public static long getEndOfDayMs(int year, int month, int day) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, day); date.set(Calendar.HOUR_OF_DAY, date.getActualMaximum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMaximum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMaximum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMaximum(Calendar.MILLISECOND)); return date.getTimeInMillis(); }
From source file:Main.java
public static String dateGraphLabelParser(long epoch) { Date date = new Date(epoch); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from ww w. ja va2 s. c o m*/ return String.format("%d/%d/%d", cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.YEAR)); }
From source file:Main.java
public static long getStartOfDayMs(int year, int month, int day) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, day); date.set(Calendar.HOUR_OF_DAY, date.getActualMinimum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMinimum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMinimum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMinimum(Calendar.MILLISECOND)); return date.getTimeInMillis(); }
From source file:Main.java
public static boolean isToday(Calendar calendar) { Calendar today = Calendar.getInstance(); return today.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && today.get(Calendar.MONTH) == calendar.get(Calendar.MONTH) && today.get(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH); }