List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static int getCurrentDayOfMonth() { Calendar calendar = Calendar.getInstance(); int currDay = calendar.get(Calendar.DAY_OF_MONTH); return currDay; }
From source file:Main.java
private static boolean isSameHalfDay(Calendar now, Calendar msg) { int nowHour = now.get(Calendar.HOUR_OF_DAY); int msgHOur = msg.get(Calendar.HOUR_OF_DAY); if (nowHour <= 12 & msgHOur <= 12) { return true; } else if (nowHour >= 12 & msgHOur >= 12) { return true; } else {//from w ww. j a va 2 s . c o m return false; } }
From source file:Main.java
public static String getMonthName(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* w ww .j a va2s. c o m*/ LocalDate localDate = LocalDate.of(0, cal.get(Calendar.MONTH) + 1, 1); return localDate.getMonth().name(); }
From source file:Main.java
private static boolean isWeekend(Calendar calendar) { int dayOfTheWeek = calendar.get(Calendar.DAY_OF_WEEK); return dayOfTheWeek == Calendar.SATURDAY || dayOfTheWeek == Calendar.SUNDAY; }
From source file:Main.java
public static String getCurrentMonth() { Calendar calendar = Calendar.getInstance(); return ((Integer) (calendar.get(Calendar.MONTH) + 1)).toString(); }
From source file:Main.java
public static int[] splitDate(Calendar calendar) { return new int[] { calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 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 String getDayOfMonth(Date date, boolean withZeroFill) { Calendar calendar = getCalendar(date); String day = (calendar.get(Calendar.DAY_OF_MONTH)) + ""; return (day.length() == 1 && withZeroFill) ? ("0" + day) : day; }
From source file:Main.java
public static Calendar nextMonday() { Calendar date = new GregorianCalendar(); while (date.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { date.add(Calendar.DATE, 1); }//from w w w . ja v a 2 s . c o m date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); return date; }
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 boolean isDayOrNight() { Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); if (hour >= 0 && hour < 18) return true; else/*from ww w.ja v a2s. com*/ return false; }