Search in sources :

Example 36 with LocalDateTime

use of org.joda.time.LocalDateTime in project joda-time-android by dlew.

the class TestDateTimeZone method testIsLocalDateTimeGap_Berlin.

//    //-----------------------------------------------------------------------
//    public void testIsLocalDateTimeOverlap_Berlin() {
//        DateTimeZone zone = DateTimeZone.forID("Europe/Berlin");
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 1, 0)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 1, 59, 59, 99)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 2, 0)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 2, 30)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 2, 59, 59, 99)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 3, 0)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 10, 28, 4, 0)));
//        
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 25, 1, 30)));  // before gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 25, 2, 30)));  // gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 25, 3, 30)));  // after gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 12, 24, 12, 34)));
//    }
//
//    //-----------------------------------------------------------------------
//    public void testIsLocalDateTimeOverlap_NewYork() {
//        DateTimeZone zone = DateTimeZone.forID("America/New_York");
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 0, 0)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 0, 59, 59, 99)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 1, 0)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 1, 30)));
//        assertEquals(true, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 1, 59, 59, 99)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 2, 0)));
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 11, 4, 3, 0)));
//        
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 11, 1, 30)));  // before gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 11, 2, 30)));  // gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 3, 11, 3, 30)));  // after gap
//        assertEquals(false, zone.isLocalDateTimeOverlap(new LocalDateTime(2007, 12, 24, 12, 34)));
//    }
//-----------------------------------------------------------------------
public void testIsLocalDateTimeGap_Berlin() {
    DateTimeZone zone = DateTimeZone.forID("Europe/Berlin");
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 1, 0)));
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 1, 59, 59, 99)));
    assertEquals(true, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 2, 0)));
    assertEquals(true, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 2, 30)));
    assertEquals(true, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 2, 59, 59, 99)));
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 3, 0)));
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 3, 25, 4, 0)));
    // before overlap
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 10, 28, 1, 30)));
    // overlap
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 10, 28, 2, 30)));
    // after overlap
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 10, 28, 3, 30)));
    assertEquals(false, zone.isLocalDateTimeGap(new LocalDateTime(2007, 12, 24, 12, 34)));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) DateTimeZone(org.joda.time.DateTimeZone)

Example 37 with LocalDateTime

use of org.joda.time.LocalDateTime in project elasticsearch by elastic.

the class SimpleJodaTests method testThatEpochTimePrinterWorks.

public void testThatEpochTimePrinterWorks() {
    StringBuffer buffer = new StringBuffer();
    LocalDateTime now = LocalDateTime.now();
    Joda.EpochTimePrinter epochTimePrinter = new Joda.EpochTimePrinter(false);
    epochTimePrinter.printTo(buffer, now, Locale.ROOT);
    assertThat(buffer.length(), is(10));
    // only check the last digit, as seconds go from 0-99 in the unix timestamp and don't stop at 60
    assertThat(buffer.toString(), endsWith(String.valueOf(now.getSecondOfMinute() % 10)));
    buffer = new StringBuffer();
    Joda.EpochTimePrinter epochMilliSecondTimePrinter = new Joda.EpochTimePrinter(true);
    epochMilliSecondTimePrinter.printTo(buffer, now, Locale.ROOT);
    assertThat(buffer.length(), is(13));
    assertThat(buffer.toString(), endsWith(String.valueOf(now.getMillisOfSecond())));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Joda(org.elasticsearch.common.joda.Joda)

Example 38 with LocalDateTime

use of org.joda.time.LocalDateTime in project head by mifos.

the class LoginServiceFacadeWebTier method changePassword.

@Override
public void changePassword(ChangePasswordRequest changePasswordRequest) {
    PersonnelBO user = this.personnelDao.findPersonnelByUsername(changePasswordRequest.getUsername());
    this.personnelService.changePassword(user, changePasswordRequest.getNewPassword(), true);
    Date newExpirationDate = null;
    if (user.getPasswordExpirationDate() != null) {
        newExpirationDate = new LocalDateTime().plusDays(PasswordRules.getPasswordExpirationDatePrelongation()).toDateTime().toDate();
    }
    personnelService.changePasswordExpirationDate(user, newExpirationDate);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 39 with LocalDateTime

use of org.joda.time.LocalDateTime in project ninja by ninjaframework.

the class ControllerMethodInvokerTest method customDateFormatParamWithOptionalShouldBeParsedToDate.

@Test
public void customDateFormatParamWithOptionalShouldBeParsedToDate() throws Exception {
    when(context.getParameter("param1")).thenReturn("15/01/2015");
    create("dateParamWithOptional", DateParamParser.class).invoke(mockController, context);
    verify(mockController).dateParamWithOptional(Optional.of(new LocalDateTime(2015, 1, 15, 0, 0).toDate()));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Test(org.junit.Test)

Example 40 with LocalDateTime

use of org.joda.time.LocalDateTime in project ninja by ninjaframework.

the class ControllerMethodInvokerTest method optionalDateParam.

@Test
public void optionalDateParam() {
    when(context.getParameter("param1")).thenReturn("15/01/2015");
    create("optionalDateParam", DateParamParser.class).invoke(mockController, context);
    verify(mockController).optionalDateParam(Optional.of(new LocalDateTime(2015, 1, 15, 0, 0).toDate()));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Test(org.junit.Test)

Aggregations

LocalDateTime (org.joda.time.LocalDateTime)66 Test (org.junit.Test)35 DateTime (org.joda.time.DateTime)15 Interval (org.joda.time.Interval)12 LocalDate (org.joda.time.LocalDate)11 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ApplianceLogger (de.avanux.smartapplianceenabler.log.ApplianceLogger)4 BigDecimal (java.math.BigDecimal)4 BigInteger (java.math.BigInteger)4 DateTimeZone (org.joda.time.DateTimeZone)4 Person (org.qi4j.test.indexing.model.Person)4 HashMap (java.util.HashMap)3 Chronology (org.joda.time.Chronology)3 LocalTime (org.joda.time.LocalTime)3 de.avanux.smartapplianceenabler.appliance (de.avanux.smartapplianceenabler.appliance)2 BuddhistChronology (org.joda.time.chrono.BuddhistChronology)2 GJChronology (org.joda.time.chrono.GJChronology)2 ISOChronology (org.joda.time.chrono.ISOChronology)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2