List of usage examples for java.util Calendar MILLISECOND
int MILLISECOND
To view the source code for java.util Calendar MILLISECOND.
Click Source Link
get
and set
indicating the millisecond within the second. From source file:Main.java
public static Calendar tomorrow() { Calendar tomorrow = new GregorianCalendar(); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); tomorrow.add(Calendar.DAY_OF_MONTH, 1); return tomorrow; }
From source file:Main.java
public static Calendar getFirstDayOfWeek() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/* w ww. java2s . co m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; }
From source file:Main.java
public static Date getTimeCurrent() { Calendar cal = Calendar.getInstance(); Date timeNow = new Date(); cal.setTime(timeNow);//ww w . java 2s.c o m // Um numero negativo vai decrementar a data cal.add(Calendar.MILLISECOND, TimeZone.getDefault().getOffset(timeNow.getTime()) * -1); return cal.getTime(); }
From source file:Main.java
public static long getDayInUTC(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time);/*from w w w . jav a 2 s. c o m*/ cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.setTimeZone(TimeZone.getTimeZone("UTC")); return cal.getTimeInMillis(); }
From source file:Main.java
public static Calendar tomorrow() { Calendar date = new GregorianCalendar(); date.add(Calendar.DATE, 1);// ww w. ja v a 2 s .c o m 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 source file:Main.java
public static long getBeginOfCurrentDateInMillis() { Calendar calendar = Calendar.getInstance(); calendar.clear(Calendar.HOUR); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); return calendar.getTimeInMillis(); }
From source file:Main.java
public static long endOfThisMonth() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); cal.add(Calendar.MONTH, 1);/* w ww . ja v a2s .co m*/ cal.add(Calendar.DATE, -1); Date date = cal.getTime(); return date.getTime(); }
From source file:Main.java
public static Long GetUTCTime() { Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); int zoneOffset = cal.get(Calendar.ZONE_OFFSET); int dstOffset = cal.get(Calendar.DST_OFFSET); cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset)); return cal.getTimeInMillis(); }
From source file:Main.java
public static void timeStamp(String tag) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); System.out.println("time stamp - " + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND) + ":" + calendar.get(Calendar.MILLISECOND) + " -- " + tag); }
From source file:Main.java
public static long getStartOfTheDay(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date);//from w ww . j ava2 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(); }