List of usage examples for org.joda.time ReadableInstant getMillis
long getMillis();
From source file:act.Act.java
License:Apache License
public static void registerTypeConverters() { TypeConverterRegistry.INSTANCE.register(new $.TypeConverter<ReadableInstant, Long>() { @Override/* ww w. j a va 2 s . c o m*/ public Long convert(ReadableInstant o) { return o.getMillis(); } }).register(new $.TypeConverter<Long, DateTime>() { @Override public DateTime convert(Long o) { return new DateTime().withMillis(o); } }).register(new $.TypeConverter<DateTime, LocalDateTime>() { @Override public LocalDateTime convert(DateTime o) { return o.toLocalDateTime(); } }).register(new $.TypeConverter<DateTime, LocalDate>() { @Override public LocalDate convert(DateTime o) { return o.toLocalDate(); } }).register(new $.TypeConverter<DateTime, LocalTime>() { @Override public LocalTime convert(DateTime o) { return o.toLocalTime(); } }); }
From source file:com.almende.timecontrol.time.Instant.java
License:Apache License
/** * {@link Instant} static factory method * //w w w.ja v a 2s . c o m * @param value */ public static Instant valueOf(final ReadableInstant joda) { return valueOf(joda.getMillis()); }
From source file:com.example.time.testing.FakeClock.java
License:Open Source License
/** * Creates a FakeClock instance initialized to the given time. */// ww w .jav a 2 s.com public FakeClock(ReadableInstant now) { baseTimeMs = now.getMillis(); fakeNowMs = new AtomicLong(baseTimeMs); }
From source file:com.example.time.testing.FakeClock.java
License:Open Source License
/** * Sets the value of the underlying instance for testing purposes. * * @return this//from ww w .j av a2s. c o m */ public FakeClock setNow(ReadableInstant now) { fakeNowMs.set(now.getMillis()); return this; }
From source file:com.google.maps.DirectionsApiRequest.java
License:Open Source License
/** * Set the arrival time for a Transit directions request. * * @param time The arrival time to calculate directions for. *///from w w w . j a v a 2s .c o m public DirectionsApiRequest arrivalTime(ReadableInstant time) { return param("arrival_time", Long.toString(time.getMillis() / 1000L)); }
From source file:com.google.maps.DirectionsApiRequest.java
License:Open Source License
/** * Set the departure time for a Transit directions request. * * @param time The departure time to calculate directions for. *///from w ww . j a v a2 s . co m public DirectionsApiRequest departureTime(ReadableInstant time) { return param("departure_time", Long.toString(time.getMillis() / 1000L)); }
From source file:com.google.maps.DistanceMatrixApiRequest.java
License:Open Source License
/** * The departure time may be specified by Maps for Work customers for to specify the * departure time to receive trip duration considering current traffic conditions. The * departure time must be set to within a few minutes of the current time. * * @param departureTime The time of departure. *///from w w w . j a va 2 s .c o m public DistanceMatrixApiRequest departureTime(ReadableInstant departureTime) { return param("departure_time", Long.toString(departureTime.getMillis() / 1000L)); }
From source file:com.metinkale.prayerapp.MainIntentService.java
License:Apache License
private void handleCalendarIntegration() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) { Prefs.setCalendar("-1"); return;/*w w w.j a v a2 s .c om*/ } Context context = App.get(); try { ContentResolver cr = context.getContentResolver(); cr.delete(CalendarContract.Events.CONTENT_URI, CalendarContract.Events.DESCRIPTION + "=\"com.metinkale.prayer\"", null); String id = Prefs.getCalendar(); if ("-1".equals(id) || (Prefs.getLanguage() == null)) { return; } int year = LocalDate.now().getYear(); Collection<int[]> days = new ArrayList<>(); days.addAll(HicriDate.getHolydays(year)); days.addAll(HicriDate.getHolydays(year + 1)); int i = 0; ContentValues[] events = new ContentValues[days.size()]; for (int[] date : days) { ContentValues event = new ContentValues(); event.put(CalendarContract.Events.CALENDAR_ID, id); event.put(CalendarContract.Events.TITLE, Utils.getHolyday(date[HicriDate.DAY] - 1)); event.put(CalendarContract.Events.DESCRIPTION, "com.metinkale.prayer"); ReadableInstant cal = new DateTime(date[HicriDate.GY], date[HicriDate.GM], date[HicriDate.GD], 0, 0, 0); long dtstart = cal.getMillis(); long dtend = dtstart + DateUtils.DAY_IN_MILLIS; event.put(CalendarContract.Events.DTSTART, dtstart + TimeZone.getDefault().getOffset(dtstart)); event.put(CalendarContract.Events.DTEND, dtend + TimeZone.getDefault().getOffset(dtend)); event.put(CalendarContract.Events.EVENT_TIMEZONE, Time.TIMEZONE_UTC); event.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED); event.put(CalendarContract.Events.ALL_DAY, 1); events[i] = event; i++; } cr.bulkInsert(CalendarContract.Events.CONTENT_URI, events); } catch (Exception e) { Prefs.setCalendar("-1"); Crashlytics.logException(e); } }
From source file:com.ning.metrics.collector.events.hadoop.writer.HadoopFileEventWriter.java
License:Apache License
@Managed(description = "seconds since last commit of events to hdfs") public long getSecondsSinceLastUpdate() { final ReadableInstant now = new DateTime(); return (now.getMillis() - lastFlushed.getMillis()) / 1000; }
From source file:com.ninja_squad.core.time.JodaClocks.java
License:Open Source License
/** * Returns an instance of a clock, that returns a current time with an offset added. * The offset is the difference between the given instant and the actual current instant * @param instant the instant at which this clock starts running, from now * @return a clock that returns the current time + the offset *//*from w w w. ja v a 2 s .c o m*/ public static JodaClock startingAt(@Nonnull ReadableInstant instant) { return new FakeOffsetJodaClock(instant.getMillis() - System.currentTimeMillis()); }