List of usage examples for java.util Calendar getTimeInMillis
public long getTimeInMillis()
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos??HinemosManager????Calendar??<br> * @param locale //w ww . ja v a2 s . c o m * @return */ public static Calendar getCalendarInstance(Locale locale) { Calendar calendar = Calendar.getInstance(getTimeZone(), locale); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:com.wanikani.wklib.UserInformation.java
public static int getDay(Date origin, Date d) { Calendar cal1, cal2; cal1 = getNormalizedCalendar(origin); cal2 = getNormalizedCalendar(d);/*from w ww . jav a2 s .com*/ return (int) ((cal2.getTimeInMillis() - cal1.getTimeInMillis()) / ONE_DAY); }
From source file:io.apiman.manager.api.core.metrics.AbstractMetricsAccessor.java
/** * @param date/*from w ww .ja v a2s.c om*/ */ protected static String formatDate(Calendar date) { return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss'Z'"); //$NON-NLS-1$ }
From source file:io.apiman.manager.api.core.metrics.AbstractMetricsAccessor.java
/** * @param date//from ww w. ja v a 2 s . co m */ protected static String formatDateWithMillis(Calendar date) { return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); //$NON-NLS-1$ }
From source file:Main.java
public static long getTimeInitializeMills(long mills) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(mills);//w ww . 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 long setTimeToMidnightAndGet(Calendar cal, long epoch) { cal.setTime(new Date(epoch)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from www.j a va 2 s .c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
/** * Copy <i>only</i> date information to a new calendar. * * @param from calendar to copy from//from w w w. j a v a2s . c o m * @param to calendar to copy to */ public static void copyDateTo(Calendar from, Calendar to) { int year = getYear(from); int month = getMonth(from); int day = getDay(from); to.clear(); to.set(year, month, day); to.getTimeInMillis(); }
From source file:Main.java
private static long calcTimeBettwenZeroAndNow() { Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.setTimeInMillis(System.currentTimeMillis()); int currentHour = calendar.get(calendar.HOUR); calendar.add(Calendar.HOUR, 24 - currentHour); return calendar.getTimeInMillis(); }
From source file:Main.java
public static long getTimesMonthStart() { Calendar cal = Calendar.getInstance(); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); return cal.getTimeInMillis(); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getFormatedDate(String rawDate, Boolean flag) { Calendar currenttime = Calendar.getInstance(); Calendar commentTime = Calendar.getInstance(); long nextDateInMillis = currenttime.getTimeInMillis(); long commentTimeInMillis = Long.parseLong(rawDate) * 1000; commentTime.setTimeInMillis(commentTimeInMillis); long timeDifferenceMilliseconds = nextDateInMillis - commentTimeInMillis; long diffSeconds = timeDifferenceMilliseconds / 1000; long diffMinutes = timeDifferenceMilliseconds / (60 * 1000); long diffHours = timeDifferenceMilliseconds / (60 * 60 * 1000); long diffDays = timeDifferenceMilliseconds / (60 * 60 * 1000 * 24); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd"); if (flag) {//w w w. jav a2 s . c o m if (diffSeconds < 1) { return "less than a second"; } else if (diffMinutes < 1) { return diffSeconds + "s"; } else if (diffHours < 1) { return diffMinutes + "m"; } else if (diffDays < 1) { return diffHours + "h"; } else if (diffDays < 7) { return diffDays + "d"; } else { return sdf.format(commentTime.getTime()); } } else { if (diffSeconds < 1) { return "Posted Just Now"; } else if (diffMinutes < 1) { if (diffSeconds == 1) return "Posted " + diffSeconds + " Second ago"; else return "Posted " + diffSeconds + " Seconds ago"; } else if (diffHours < 1) { if (diffMinutes == 1) return "Posted " + diffMinutes + " Month ago"; else return "Posted " + diffMinutes + " Months ago"; } else if (diffDays < 1) { if (diffHours == 1) return "Posted " + diffHours + " hour ago"; else return "Posted " + diffHours + " hours ago"; } else if (diffDays < 7) { if (diffDays == 1) return "Posted " + diffDays + " day ago"; else return "Posted " + diffDays + " days ago"; } else { return "Posted on " + sdf.format(commentTime.getTime()); } } }