List of usage examples for java.util Calendar HOUR_OF_DAY
int HOUR_OF_DAY
To view the source code for java.util Calendar HOUR_OF_DAY.
Click Source Link
get
and set
indicating the hour of the day. From source file:Main.java
public static String getNowTime() { Calendar nowTime = Calendar.getInstance(); nowTime.add(Calendar.HOUR_OF_DAY, 8); return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(nowTime.getTime()); }
From source file:Main.java
public static Calendar today() { 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, 0); return date;/*from w w w . j av a 2 s .c o m*/ }
From source file:Main.java
public static Calendar GetTodayLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static long timeInMillis(int hour, int minute) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, 0); long timeBefore = calendar.getTimeInMillis(); if (Calendar.getInstance().getTimeInMillis() > timeBefore) calendar.add(Calendar.DAY_OF_WEEK, 1); return calendar.getTimeInMillis(); }
From source file:Main.java
public static int getHourFromDate(Date date) { Calendar cal = dateToCalendar(date); return cal.get(Calendar.HOUR_OF_DAY); }
From source file:Main.java
public static Calendar GetTodayRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static long startOfTodDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date date = calendar.getTime(); return date.getTime(); }
From source file:Main.java
public static Calendar GetYesterdayLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static int getHour(Date date) { return getCalendar(date).get(Calendar.HOUR_OF_DAY); }
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(); }