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 long getStartOfWeek(long week) { Calendar calendar = getCalendarWithTime(week); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); // get start of this week in milliseconds calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); return calendar.getTimeInMillis(); }
From source file:Main.java
public static String getCurrentTime() { Calendar calendar = Calendar.getInstance(); return getToday() + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE); }
From source file:Main.java
public static String getClockTimeFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);// w w w . j a v a2 s . c om return String.format("%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); }
From source file:Main.java
public static long getTimeLongTenHours(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day);/*from w w w . j a v a2 s .c o m*/ calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); }
From source file:Main.java
public static String getTime(int laterTime) { Calendar calendar = Calendar.getInstance(); if (laterTime != 0) calendar.add(Calendar.HOUR_OF_DAY, 1); return new SimpleDateFormat("hh:mm a").format(calendar.getTime()); }
From source file:Main.java
public static Calendar GetThisMonthLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); 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 Calendar GetLastMonthRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); 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 Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from w w w. j a v a 2 s . c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static Calendar GetLastMonthLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); 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.MONTH, -1); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Date round2Day(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);// ww w .j av a 2 s .co m cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }