Example usage for java.time LocalDateTime of

List of usage examples for java.time LocalDateTime of

Introduction

In this page you can find the example usage for java.time LocalDateTime of.

Prototype

public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second) 

Source Link

Document

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

Usage

From source file:org.fcrepo.integration.http.api.FedoraVersioningIT.java

@Test
public void testGetTimeMapResponseMultipleMementos() throws Exception {
    createVersionedContainer(id);/*from  w w w .  j ava 2  s  .  c o  m*/
    final String memento1 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(2000, 1, 1, 00, 00, 00).atOffset(ZoneOffset.UTC));
    final String memento2 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(2015, 8, 13, 18, 30, 0).atOffset(ZoneOffset.UTC));
    final String memento3 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(1980, 5, 31, 9, 15, 30).atOffset(ZoneOffset.UTC));
    createContainerMementoWithBody(subjectUri, memento1);
    createContainerMementoWithBody(subjectUri, memento2);
    createContainerMementoWithBody(subjectUri, memento3);
    final String[] mementos = { memento1, memento2, memento3 };
    verifyTimemapResponse(subjectUri, id, mementos, memento3, memento2);
}

From source file:org.jbb.frontend.impl.format.LocalDateTimeFormatterTest.java

@Test
public void shouldFormatLocalDateTimeToString() throws Exception {
    // given//  www  .  j  av a 2 s  .  co m
    LocalDateTime dateTime = LocalDateTime.of(2016, 12, 19, 17, 5, 22);

    // when
    LocalDateTimeFormatter formatter = new LocalDateTimeFormatter(propertiesMock);
    String dateTimeString = formatter.print(dateTime, Locale.getDefault());

    // then
    assertThat(dateTimeString).isEqualTo("19/12/2016 17:05:22");
}

From source file:org.jbb.frontend.impl.format.LocalDateTimeFormatterTest.java

@Test
public void shouldParseStringToLocalDateTime() throws Exception {
    // given//from   w  w w. jav  a 2  s.  c  om
    String dateTimeString = "19/12/2016 17:05:22";
    LocalDateTime expectedDateTime = LocalDateTime.of(2016, 12, 19, 17, 5, 22);

    // when
    LocalDateTimeFormatter formatter = new LocalDateTimeFormatter(propertiesMock);
    LocalDateTime dateTime = formatter.parse(dateTimeString, Locale.getDefault());

    // then
    assertThat(dateTime).isEqualTo(expectedDateTime);
}

From source file:org.jgrades.lic.service.LicenceManagingServiceImplTest.java

private Licence getLicence1() {
    Licence licence = new Licence();
    licence.setUid(42L);//from w w w  .  ja v a2  s.com

    Customer customer = new Customer();
    customer.setId(1L);
    customer.setName("XIV LO");
    customer.setAddress("Wroclaw");
    customer.setPhone("+48 71 234 56 78");
    licence.setCustomer(customer);

    Product product = new Product();
    product.setName("JG-BASE");
    product.setVersion("0.4-DEV-SNAPSHOT");
    product.setValidFrom(LocalDateTime.of(2015, 7, 25, 0, 0, 0));
    product.setValidTo(LocalDateTime.of(2016, 7, 25, 0, 0, 0));
    licence.setProduct(product);

    LicenceProperty property = new LicenceProperty();
    property.setName("expiredDays");
    property.setValue("14");
    List<LicenceProperty> properties = Lists.newArrayList(property);
    licence.setProperties(properties);

    return licence;
}

From source file:org.jgrades.lic.service.LicenceManagingServiceImplTest.java

private Licence getLicence2() {
    Licence licence = new Licence();
    licence.setUid(43L);//  w w w  .  j  a va 2 s  . c o  m

    Customer customer = new Customer();
    customer.setId(2L);
    customer.setName("XIII LO");
    customer.setAddress("Wroclaw");
    customer.setPhone("+48 71 234 56 78");
    licence.setCustomer(customer);

    Product product = new Product();
    product.setName("JG-BASE");
    product.setVersion("0.4-DEV-SNAPSHOT");
    product.setValidFrom(LocalDateTime.of(2015, 7, 25, 0, 0, 0));
    product.setValidTo(LocalDateTime.of(2016, 7, 25, 0, 0, 0));
    licence.setProduct(product);

    LicenceProperty property = new LicenceProperty();
    property.setName("expiredDays");
    property.setValue("14");
    List<LicenceProperty> properties = Lists.newArrayList(property);
    licence.setProperties(properties);

    return licence;
}

From source file:tech.tablesaw.filters.SearchPerformanceTest.java

private static void generateTestData(Table t, int numberOfRecordsInTable, Stopwatch stopwatch)
        throws IOException {
    stopwatch.reset().start();/*from ww w. jav a 2s  . com*/
    out.println("Generating test data");
    LocalDateTime startDateTime = LocalDateTime.of(2008, 1, 1, 0, 0, 0);
    generateData(numberOfRecordsInTable, startDateTime, t);
    out.println("Time to generate " + numberOfRecordsInTable + " records: "
            + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");
}