List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:ota.otaupdates.utils.Utils.java
public static String getDate(long time) { Calendar cal = Calendar.getInstance(Locale.getDefault()); cal.setTimeInMillis(time); return DateFormat.format("dd-MM-yyyy", cal).toString(); }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos?????Calendar??<br>//from w w w .ja va2s.co m * @param timezone * @return */ public static Calendar getCalendarInstance(TimeZone timezone) { Calendar calendar = Calendar.getInstance(timezone); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos??HinemosManager????Calendar??<br> * @return//from www. j av a 2 s.co m */ public static Calendar getCalendarInstance() { Calendar calendar = Calendar.getInstance(getTimeZone()); calendar.setTimeInMillis(HinemosTime.currentTimeMillis()); return calendar; }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos?????Calendar??<br>/* w ww.j a va 2s . com*/ * @param timezone * @param locale * @return */ public static Calendar getCalendarInstance(TimeZone timezone, Locale locale) { Calendar calendar = Calendar.getInstance(timezone, locale); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:de.kurashigegollub.dev.gcatest.Utils.java
public static DateTime getDateTime2Weeks(DateTime dtFrom) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(dtFrom.getValue()); c.add(Calendar.WEEK_OF_YEAR, 2); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59);//from ww w . ja v a2 s .com c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 999); return new DateTime(c.getTime(), TimeZone.getDefault()); }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos??HinemosManager????Calendar??<br> * @param locale // w w w . j av a 2 s .com * @return */ public static Calendar getCalendarInstance(Locale locale) { Calendar calendar = Calendar.getInstance(getTimeZone(), locale); calendar.setTimeInMillis(calendar.getTimeInMillis() + timeOffsetMillis); return calendar; }
From source file:Main.java
public static boolean areSameDays(long time1, long time2) { Calendar calendar = calendarThreadLocal.get(); if (calendar == null) { calendar = Calendar.getInstance(); calendarThreadLocal.set(calendar); }//from w w w. jav a2 s . c o m calendar.setTimeInMillis(time1 * 1000L); int y1 = calendar.get(Calendar.YEAR); int m1 = calendar.get(Calendar.MONTH); int d1 = calendar.get(Calendar.DATE); calendar.setTimeInMillis(time2 * 1000L); int y2 = calendar.get(Calendar.YEAR); int m2 = calendar.get(Calendar.MONTH); int d2 = calendar.get(Calendar.DATE); return y1 == y2 && m1 == m2 && d1 == d2; // return (time1 / (60 * 60 * 24)) == (time2 / (60 * 60 * 24)); }
From source file:at.florian_lentsch.expirysync.NotifyChecker.java
/** * Sets the alarm that checks for products soon to expire (or already have * expired)/*from ww w . j a v a 2s . c o m*/ * * @param context */ protected static void setAlarm(Context context) { Context appContext = context.getApplicationContext(); Intent receiverIntent = new Intent(appContext, NotifyChecker.class); // Fetch info about when the alarm is to sound each day from the shared // preferences: long firstStartMillis = getFirstStartMillis(appContext); if (firstStartMillis < 0) { Log.i("Alarm", "Alert time not configured - not setting alarm"); return; } Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(firstStartMillis); // Log.i("Alarm", "Setting alarm: " + firstStartMillis + ", " + (new // SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", // Locale.US)).format(firstStartMillis)); // Set the alarm: PendingIntent alarmIntent = PendingIntent.getBroadcast(appContext, 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmMgr = (AlarmManager) appContext.getSystemService(Context.ALARM_SERVICE); alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, firstStartMillis, AlarmManager.INTERVAL_DAY, alarmIntent); }
From source file:org.traccar.WebDataHandler.java
private static String formatSentence(Position position) { StringBuilder s = new StringBuilder("$GPRMC,"); try (Formatter f = new Formatter(s, Locale.ENGLISH)) { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ENGLISH); calendar.setTimeInMillis(position.getFixTime().getTime()); f.format("%1$tH%1$tM%1$tS.%1$tL,A,", calendar); double lat = position.getLatitude(); double lon = position.getLongitude(); f.format("%02d%07.4f,%c,", (int) Math.abs(lat), Math.abs(lat) % 1 * 60, lat < 0 ? 'S' : 'N'); f.format("%03d%07.4f,%c,", (int) Math.abs(lon), Math.abs(lon) % 1 * 60, lon < 0 ? 'W' : 'E'); f.format("%.2f,%.2f,", position.getSpeed(), position.getCourse()); f.format("%1$td%1$tm%1$ty,,", calendar); }/*from w w w .j a v a 2 s .co m*/ s.append(Checksum.nmea(s.toString())); return s.toString(); }
From source file:com.espertech.esper.client.util.DateTime.java
/** * Parse the date-time string using {@link #DEFAULT_XMLLIKE_DATE_FORMAT}. * @param dateTime date-time string// w ww.j av a2s .c om * @return calendar */ public static Calendar parseDefaultCal(String dateTime) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(parseDefaultMSec(dateTime)); return cal; }