List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static int getMonth() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.MONTH) + 1; }
From source file:Main.java
public static int getCurrentMonth() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.MONTH) + 1; }
From source file:Main.java
public static int getNowDay() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.DATE); }
From source file:Main.java
public static String getFlushYear() { Calendar cal = Calendar.getInstance(); int i = cal.get(Calendar.YEAR); String s = Integer.toString(i); return s;/*from ww w. j a v a 2 s . c om*/ }
From source file:Main.java
public static long getTimesMonthMorning() { 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(); }
From source file:Main.java
public static Timestamp getCurrentDate() { Calendar c = Calendar.getInstance(); c.set(c.get(1), c.get(2), c.get(5), 0, 0, 0); Timestamp t = new Timestamp(c.getTime().getTime()); t.setNanos(0);/*from w w w.jav a 2s. c o m*/ return t; }
From source file:Main.java
public static long getTimesMonthNextStart() { 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.getActualMaximum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, 24); return cal.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); }
From source file:Main.java
public static int getCurrentDayOfWeekFromTimestamp() { Calendar currentTime = Calendar.getInstance(); return currentTime.get(Calendar.DAY_OF_WEEK); }
From source file:Main.java
public static int getCurrentTimeStamp() { Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); return 60 * hour + minute; }