@Test
public void floorToQuarterHour() throws Exception {

    // create a reference datetime
    DateTime dt0 = new DateTime(2009,6,24,23,29,30,789,DateTimeZone.UTC);
    Assert.assertNull(DateTimeUtil.floorToQuarterHour(null));
    
    // floor to nearest half hour
    DateTime dt1 = DateTimeUtil.floorToQuarterHour(dt0);
    Assert.assertEquals(2009, dt1.getYear());
    Assert.assertEquals(6, dt1.getMonthOfYear());
    Assert.assertEquals(24, dt1.getDayOfMonth());
    Assert.assertEquals(23, dt1.getHourOfDay());
    Assert.assertEquals(15, dt1.getMinuteOfHour());
    Assert.assertEquals(0, dt1.getSecondOfMinute());
    Assert.assertEquals(0, dt1.getMillisOfSecond());
    Assert.assertEquals(DateTimeZone.UTC, dt1.getZone());
    DateTime dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,0,0,0));
    Assert.assertEquals(new DateTime(2009,6,24,10,0,0,0), dt3);
    dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,1,23,456));
    Assert.assertEquals(new DateTime(2009,6,24,10,0,0,0), dt3);
    dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,30,12,56));
    Assert.assertEquals(new DateTime(2009,6,24,10,30,0,0), dt3);
    dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,59,59,999));
    Assert.assertEquals(new DateTime(2009,6,24,10,45,0,0), dt3);
    dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,55,59,999));
    Assert.assertEquals(new DateTime(2009,6,24,10,45,0,0), dt3);
    dt3 = DateTimeUtil.floorToQuarterHour(new DateTime(2009,6,24,10,46,59,999));
    Assert.assertEquals(new DateTime(2009,6,24,10,45,0,0), dt3);
}