List of usage examples for org.joda.time DateTime withMillisOfSecond
public DateTime withMillisOfSecond(int millis)
From source file:com.arpnetworking.kairosdb.aggregators.MovingWindowAggregator.java
License:Apache License
/** * For YEARS, MONTHS, WEEKS, DAYS: Computes the timestamp of the first * millisecond of the day of the timestamp. For HOURS, Computes the timestamp of * the first millisecond of the hour of the timestamp. For MINUTES, Computes the * timestamp of the first millisecond of the minute of the timestamp. For * SECONDS, Computes the timestamp of the first millisecond of the second of the * timestamp. For MILLISECONDS, returns the timestamp * * @param timestamp Timestamp in milliseconds to use as a basis for range alignment * @return timestamp aligned to the configured sampling unit *///w w w . j ava2s.c om @SuppressWarnings("fallthrough") @SuppressFBWarnings("SF_SWITCH_FALLTHROUGH") private long alignRangeBoundary(final long timestamp) { DateTime dt = new DateTime(timestamp, _timeZone); final TimeUnit tu = m_sampling.getUnit(); switch (tu) { case YEARS: dt = dt.withDayOfYear(1).withMillisOfDay(0); break; case MONTHS: dt = dt.withDayOfMonth(1).withMillisOfDay(0); break; case WEEKS: dt = dt.withDayOfWeek(1).withMillisOfDay(0); break; case DAYS: dt = dt.withHourOfDay(0); case HOURS: dt = dt.withMinuteOfHour(0); case MINUTES: dt = dt.withSecondOfMinute(0); case SECONDS: default: dt = dt.withMillisOfSecond(0); break; } return dt.getMillis(); }
From source file:com.cfelde.cron4joda.Predictor.java
License:Open Source License
/** * It builds a predictor with the given scheduling pattern and start time. * //from ww w . j av a 2 s . com * The time zone setting of the given DateTime will be used as the basis * of the cron pattern. * * @param schedulingPattern The pattern on which the prediction will be * based. * @param start The start time of the prediction. * @since 2.0 */ public Predictor(SchedulingPattern schedulingPattern, DateTime start) { this.schedulingPattern = schedulingPattern; this.dt = start.withMillisOfSecond(0).withSecondOfMinute(0); }
From source file:com.citruspay.JDateUtil.java
License:Open Source License
/*** * Returns the start of date of a given date. * //from www. j a v a2 s .co m * @param date * @return */ public static DateTime startOfDay(DateTime date) { return date.withMillisOfSecond(0).withSecondOfMinute(0).withMinuteOfHour(0).withHourOfDay(0); }
From source file:com.collective.celos.Util.java
License:Apache License
public static DateTime toFullSecond(DateTime dt) { return dt.withMillisOfSecond(0); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime thirtySeconds(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); if (dateTime.getSecondOfMinute() < 30) { return dateTime.withSecondOfMinute(0); } else {/*w ww . ja v a2s . c om*/ return dateTime.withSecondOfMinute(30); } }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime oneMinute(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); return dateTime.withSecondOfMinute(0); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime fiveMinutes(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); int minutes = dateTime.getMinuteOfHour(); return dateTime.withMinuteOfHour(minutes / 5 * 5); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime thirtyMinutes(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); if (dateTime.getMinuteOfHour() < 30) { return dateTime.withMinuteOfHour(0); } else {// www. j a v a 2s. c o m return dateTime.withMinuteOfHour(30); } }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime oneHour(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); return dateTime.withMinuteOfHour(0); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime twelveHours(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); dateTime = dateTime.withMinuteOfHour(0); if (dateTime.getHourOfDay() < 12) { return dateTime.withHourOfDay(0); } else {//from w ww . jav a 2 s.com return dateTime.withHourOfDay(12); } }