List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static int getDayOfYear() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.DAY_OF_YEAR); return year;//from www. j a va 2 s . c om }
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 boolean isExpire(Calendar expireTime) { Calendar now = Calendar.getInstance(); if (now.compareTo(expireTime) >= 0) { return true; } else {/*from ww w. j av a 2 s .com*/ return false; } }
From source file:Main.java
public static int getDayOfMonth() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.DAY_OF_MONTH); return year;//from w ww.ja v a2 s .c o m }
From source file:Main.java
public static Date getYesterday() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); return cal.getTime(); }
From source file:Main.java
public static Calendar newInitializedCalendar() { Calendar newitem = Calendar.getInstance(); newitem.set(Calendar.HOUR, 0); newitem.set(Calendar.MINUTE, newitem.getMinimum(Calendar.MINUTE)); newitem.set(Calendar.SECOND, newitem.getMinimum(Calendar.SECOND)); newitem.set(Calendar.MILLISECOND, newitem.getMinimum(Calendar.MILLISECOND)); return newitem; }
From source file:Main.java
public static int getdataCount(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); int count = cal.getActualMaximum(Calendar.DATE); return count; }
From source file:Main.java
public static int getWeek(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK) - 1; }
From source file:Main.java
private static Calendar getTodayAutoPushTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static int getDays(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.clear();/* w w w . j av a 2s. com*/ calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); return days; }