Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created June 4, 2012 14:30
Show Gist options
  • Save jsanda/2868731 to your computer and use it in GitHub Desktop.
Save jsanda/2868731 to your computer and use it in GitHub Desktop.
private DateTime get6HourTimeSlice(DateTime dateTime) {
Chronology chronology = GregorianChronology.getInstance();
DateTimeField hourField = chronology.hourOfDay();
DividedDateTimeField dividedField = new DividedDateTimeField(hourField, DateTimeFieldType.clockhourOfDay(), 6);
long timestamp = dividedField.roundFloor(dateTime.getMillis());
return new DateTime(timestamp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment