List of usage examples for java.util Calendar SECOND
int SECOND
To view the source code for java.util Calendar SECOND.
Click Source Link
get
and set
indicating the second within the minute. From source file:Main.java
public static String millisToDate(long currentTime) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(currentTime); return calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND) + " " + (calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM"); }
From source file:Main.java
public static long getStartOfTheDay(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date);/*from w w w. j a v a 2s .co 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 Calendar initCalendar(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);// www .j a va 2 s. c o m calendar.set(Calendar.HOUR, 10); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 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 ww 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 Date round2Day(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* ww w. j ava 2s . c o 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(); }
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
/** * Clean hours, minutes, seconds and milliseconds * @param c Calendar to clean/* www . jav a 2s . c om*/ */ 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 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 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; }