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 getTimeMillisAsHourAndMinute(long millis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis);/* w ww . j a v a 2 s . c om*/ int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); return calendar.getTimeInMillis(); }
From source file:Main.java
public static long getStartOfTheDay(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date);/*from www. j av a 2 s. c o m*/ c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTimeInMillis(); }
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:Main.java
public static String getDeadTime(int unit, int amount) { Calendar nowTime = Calendar.getInstance(); nowTime.add(unit, amount);/*from w w w . j ava 2 s.c o m*/ nowTime.add(Calendar.HOUR_OF_DAY, 8); return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(nowTime.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:Main.java
/** * Clean hours, minutes, seconds and milliseconds * @param c Calendar to clean//from w w w.j a v a2 s . com */ public static void cleanDay(Calendar c) { c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); }
From source file:Main.java
public static final long getValidTime(TimePicker timePicker) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour().intValue()); c.set(Calendar.MINUTE, timePicker.getCurrentMinute().intValue()); return c.getTimeInMillis(); }
From source file:Main.java
public static Date firstTimeOfWeek(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); Date dateBegin = new Date(); dateBegin.setTime(calendar.getTimeInMillis()); return dateBegin; }
From source file:Main.java
public static long getYearMonthDay(long date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date);/*from www . j a va 2 s.com*/ calendar.set(Calendar.HOUR_OF_DAY, 0); 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 int getHour(Date date) { calendar = Calendar.getInstance(); calendar.setTime(date);// w ww . jav a 2 s. co m return calendar.get(Calendar.HOUR_OF_DAY); }