List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static boolean isSameTime(Calendar startTime, Calendar endTime) { if (startTime.get(Calendar.HOUR) == endTime.get(Calendar.HOUR) && startTime.get(Calendar.MINUTE) == endTime.get(Calendar.MINUTE)) return true; else// ww w . j a v a2 s . c o m return false; }
From source file:Main.java
public static boolean isWeekend() { Calendar now = Calendar.getInstance(); return (now.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) || (now.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY); }
From source file:Main.java
private static Calendar getCurrentExpDate() { Calendar now = Calendar.getInstance(); now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 0, 0, 0); return now;//from w ww . ja v a 2s. co m }
From source file:Main.java
/** * Retrieves a printable minute value from the calendar to be used within a time. For example, minute 3 will be * returned as 03 (so to display 10:03 instead of 10:3) * @param calendar The calendar object whose minute value to retrieve * @return printable minute value from the calendar object *//*from w w w . j ava 2s .c o m*/ public static String getDisplayableMinute(Calendar calendar) { return calendar.get(Calendar.MINUTE) < 10 ? "0" + calendar.get(Calendar.MINUTE) : String.valueOf(calendar.get(Calendar.MINUTE)); }
From source file:Main.java
public static boolean equals(Calendar cal1, Calendar cal2) { int year1 = cal1.get(Calendar.YEAR); int dayOfYear1 = cal1.get(Calendar.DAY_OF_YEAR); int year2 = cal2.get(Calendar.YEAR); int dayOfYear2 = cal2.get(Calendar.DAY_OF_YEAR); return year1 == year2 && dayOfYear1 == dayOfYear2; }
From source file:Main.java
public static boolean isNowBeforeSixAM() { Calendar today = Calendar.getInstance(); return ((today.get(Calendar.HOUR_OF_DAY) < 6 && (today.get(Calendar.HOUR_OF_DAY) >= 0) ? true : false)); }
From source file:Main.java
public static boolean isInSameDay(Calendar calendar1, Calendar calendar2) { return 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); }
From source file:Main.java
public static int getCurrentMonthOfYear() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.MONTH); }
From source file:Main.java
public static int getCurrentDayOfMonth() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static long getTimesMonthStart() { Calendar cal = Calendar.getInstance(); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); return cal.getTimeInMillis(); }