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 updateCalendarTimeAndGetFormat(Calendar cal, int hourOfDay, int minute) { cal.set(Calendar.HOUR_OF_DAY, hourOfDay); cal.set(Calendar.MINUTE, minute); return defaultTimeFormat.format(cal.getTime()); }
From source file:Main.java
/** * the hour of hte day// w ww .j av a 2 s.co m * * @return */ private static int hourOfTheDay() { final Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.HOUR_OF_DAY); }
From source file:Main.java
public static Date getTheBeginingOfDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);// www . j av a 2 s .c o m calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); }
From source file:Main.java
public static Calendar GetThisYearLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.MONTH, 0); 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 GetLastYearRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.MONTH, 0); 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
/** * @return Return current day timestamp with YY, MM, dd info ONLY *//* ww w .j a v a 2s . c o m*/ public static Long getCurrentDayTS() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
public static Calendar transformStringTimeToCalendar(String time) { Calendar calendar = Calendar.getInstance(); String[] split = time.split(":"); if (split.length > 0) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(split[0])); }/*from w w w . j a va 2s. co m*/ if (split.length > 1) { calendar.set(Calendar.MINUTE, Integer.parseInt(split[1])); } if (split.length > 2) { calendar.set(Calendar.SECOND, Integer.parseInt(split[2])); } return calendar; }
From source file:Main.java
public static String getTime() { StringBuffer sb = new StringBuffer(); Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); int hour = c.get(Calendar.HOUR_OF_DAY); int minutes = c.get(Calendar.MINUTE); if (hour < 10) { sb.append(0);//from w ww . ja v a 2s . co m sb.append(hour); } else { sb.append(hour); } sb.append(':'); if (minutes < 10) { sb.append(0); sb.append(minutes); } else { sb.append(minutes); } return sb.toString(); }
From source file:Main.java
public static long getTimeStampStartOfDay(long time) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(new Date(time)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/* w w w . j a v a 2s .c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
public static String getYesterdayFormattedTime() { Calendar calendar = getCurrentCalendar(); calendar.add(Calendar.HOUR_OF_DAY, -9); calendar.add(Calendar.DAY_OF_MONTH, -1); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); String result = format.format(calendar.getTime()); String standardName = ""; if (result.contains("JST")) { standardName = "JST"; result = result.replaceAll(standardName, "+09:00"); } else if (result.contains("GMT")) { standardName = "GMT"; result = result.replaceAll(standardName, ""); }/* ww w. j a va 2s . co m*/ return result; }