List of usage examples for java.util GregorianCalendar GregorianCalendar
public GregorianCalendar()
GregorianCalendar
using the current time in the default time zone with the default Locale.Category#FORMAT FORMAT locale. From source file:Main.java
public static Calendar tomorrow() { Calendar date = new GregorianCalendar(); date.add(Calendar.DATE, 1);//from w w w . jav a 2 s . co 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 boolean isFridayOrSaturday() { Calendar date = new GregorianCalendar(); return date.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY || date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY; }
From source file:Main.java
public static long getTodayStartTime() { Calendar date = new GregorianCalendar(); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 1); return date.getTimeInMillis(); }
From source file:Main.java
public static Calendar tomorrow() { Calendar tomorrow = new GregorianCalendar(); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); tomorrow.add(Calendar.DAY_OF_MONTH, 1); return tomorrow; }
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 ww .j a 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 float getPercentOfDay() { GregorianCalendar cal = new GregorianCalendar(); float dayMillis = 0; dayMillis += (cal.get(Calendar.HOUR_OF_DAY) * 60 * 60); dayMillis += (cal.get(Calendar.MINUTE) * 60); dayMillis += cal.get(Calendar.SECOND); float totalDayMillis = (24f * 60f * 60f); return (dayMillis / totalDayMillis); }
From source file:DateUtils.java
public static Date getYesterday() { GregorianCalendar yesterday = new GregorianCalendar(); yesterday.add(Calendar.DATE, -1); return yesterday.getTime(); }
From source file:Main.java
public static int gettimeinhours(long t) { Calendar c = new GregorianCalendar(); c.setTime(new Date(t)); return c.get(Calendar.HOUR_OF_DAY); }
From source file:DateUtils.java
public static Date getLastWeek() { GregorianCalendar dayBeforeThisWeek = new GregorianCalendar(); int dayFromMonday = (dayBeforeThisWeek.get(Calendar.DAY_OF_WEEK) + 7 - Calendar.MONDAY) % 7; dayBeforeThisWeek.add(Calendar.DATE, -dayFromMonday - 1); return dayBeforeThisWeek.getTime(); }
From source file:Main.java
public static GregorianCalendar getCalendar(Date day) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(day);//from www . ja v a 2s. co m return gregorianCalendar; }