Example usage for java.time LocalDateTime now

List of usage examples for java.time LocalDateTime now

Introduction

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

Prototype

public static LocalDateTime now() 

Source Link

Document

Obtains the current date-time from the system clock in the default time-zone.

Usage

From source file:org.jgrades.backup.creator.StartBackupJob.java

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

    LocalDateTime scheduledDateTime = LocalDateTime.now();
    String backupName = getBackupName(scheduledDateTime);
    File backupInstanceDir = new File(backupDirectory + File.separator + backupName);

    Backup backup = saveBackupMetadataToDb(scheduledDateTime, backupName, backupInstanceDir);
    BackupEvent event = saveBackupEventMetadataToDb(backup);

    tryToCreateBackupFolder(backupInstanceDir, backup, event);

    insertBackupToSchedulerContext(context, backup);
}

From source file:sample.service.OrderService.java

public Order createNewOrder(String username, Cart cart) {
    Account account = accountDao.selectAccountByUsername(username);

    Order order = new Order();
    order.setUsername(account.getUsername());
    order.setOrderDate(LocalDateTime.now());
    order.setShipToFirstName(account.getFirstName());
    order.setShipToLastName(account.getLastName());
    order.setShipAddress1(account.getAddress1());
    order.setShipAddress2(account.getAddress2());
    order.setShipCity(account.getCity());
    order.setShipState(account.getState());
    order.setShipZip(account.getZip());//from   w  ww.ja v a 2 s .c  o  m
    order.setShipCountry(account.getCountry());
    order.setBillToFirstName(account.getFirstName());
    order.setBillToLastName(account.getLastName());
    order.setBillAddress1(account.getAddress1());
    order.setBillAddress2(account.getAddress2());
    order.setBillCity(account.getCity());
    order.setBillState(account.getState());
    order.setBillZip(account.getZip());
    order.setBillCountry(account.getCountry());
    order.setTotalPrice(cart.getSubTotal());
    order.setCreditCard("999 9999 9999 9999");
    order.setExpiryDate("12/03");
    order.setCardType("Visa");
    order.setCourier("UPS");
    order.setLocale("CA");
    order.setStatus("P");
    return order;
}

From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java

@Test
public void testCreateThenGetHappyPath() throws IOException {
    Resource r = resolver.getResource("classpath:TestSelectQuery.json");
    String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset());
    NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class);
    namedQueryService.create(namedQuery);

    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("createdTime", LocalDateTime.now().plusDays(1).toString());
    String result = namedQueryService.get("getAttributesCreatedBefore", params);
    String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" };
    List<String> actual = JsonPath.given(result).getList("name");
    Assertions.assertTrue(actual.containsAll(Arrays.asList(expected)));
}

From source file:fi.vrk.xroad.catalog.persistence.TestUtil.java

public Member createTestMember(String name) {
    LocalDateTime now = LocalDateTime.now();
    Member member = new Member();
    member.setName(name);/*from ww w  .  j a v  a2 s.c  o  m*/
    member.setXRoadInstance("FI");
    member.setMemberClass("GOV");
    member.setMemberCode("code-" + name);
    member.getStatusInfo().setCreated(now);
    member.getStatusInfo().setChanged(now);

    Subsystem ss1 = createSubsystem(name, now, "ss1");
    Subsystem ss2 = createSubsystem(name, now, "ss2");
    ss1.setMember(member);
    ss2.setMember(member);
    member.setSubsystems(new HashSet<>());
    member.getAllSubsystems().add(ss1);
    member.getAllSubsystems().add(ss2);

    Service s1 = createService(name, now, "service1");
    Service s2 = createService(name, now, "service2");
    s1.setSubsystem(ss1);
    s2.setSubsystem(ss1);
    ss1.setServices(new HashSet<>());
    ss1.getAllServices().add(s1);
    ss1.getAllServices().add(s2);

    Wsdl wsdl = new Wsdl();
    s1.setWsdl(wsdl);
    wsdl.setService(s1);
    wsdl.setData("<?xml version=\"1.0\" standalone=\"no\"?><wsdl/>");
    wsdl.setExternalId("external-id-" + name);
    wsdl.getStatusInfo().setTimestampsForNew(now);

    return member;
}

From source file:org.jspare.jsdbc.JsdbcMockedImpl.java

@Override
public StatusResult status() throws JsdbcException {

    return new StatusResult(Status.SUCCESS, LocalDateTime.now(), "tid", "OK", LocalDateTime.now());
}

From source file:com.blurengine.blur.modules.maploading.LocalArchiver.java

public boolean archive(File file) {
    String archiveName = nameTemplate.replaceAll("\\{mapname\\}", file.getName()).replaceAll("\\{datetime\\}",
            dtf.format(LocalDateTime.now()).replaceAll("[+-]+", "-")); // remove + and : in time

    // Precaution against fools who delete the archives directory after load.
    if (!directory.exists()) {
        directory.mkdirs();//w ww .  java  2 s . co m
    }
    return compressor.compress(file, archiveName);
}

From source file:com.ccserver.digital.service.CreditCardApplicationExtractionServiceTest.java

@Test
public void extractByteArrayExcelTestIsEmpty() throws IOException {

    CreditCardApplicationExtration cr = new CreditCardApplicationExtration();
    cr.setBranchAddress("Branh");
    cr.setBusinessAddress("Address");
    cr.setBusinessPhone("phone");
    cr.setBusinessStartDate(LocalDateTime.now());
    cr.setBusinessTelephone("Phone");
    cr.setCitizenship("ship");
    cr.setCurrentAddress("address");
    cr.setCurrentIsPermanent("payment");
    cr.setDateOfIssue(LocalDateTime.now());
    cr.setEducation("education");
    cr.setEmail("Email");
    cr.setFirstName("firname");
    cr.setLastName("lastName");
    cr.setGender("");
    cr.setGeneral_phone("");
    cr.setHave_green_card("");
    cr.setIndustry("");
    cr.setIsSecondaryCard("");
    cr.setIsUSResident("");
    cr.setLicenseNumber("");
    cr.setMaritalStatus("");
    cr.setMiddleName("");
    cr.setMonthlyExpenses(new BigDecimal("11"));
    cr.setMonthlyIncome(new BigDecimal("11"));
    cr.setMonthsOfWorking(1);// w w w .  j  av a 2  s .c o  m
    cr.setNumberOfChildren(1);
    cr.setPassportNumber("");
    cr.setPermanentAddress("");
    cr.setPhoneOfReference("");
    cr.setPlaceOfIssue("");
    cr.setReferenceName("");
    cr.setRelationshipReference("");
    cr.setSecurityAnswer("");
    cr.setSecurityQuestion("");
    cr.setTypeOfEmployement("");
    cr.setYearsOfWorking(1);
    Mockito.when(repository.findAll()).thenReturn(null);
    byte[] result = ccAppExtractionService.extractCreditCard(1);
    Assert.assertNull(result);

}

From source file:no.ntnu.okse.core.messaging.Message.java

/**
 * Constructor that takes in a message, topic, publisher and originProtocol to produce a single OKSE Message
 *
 * @param message        The message content, represented as a string (Cannot be null)
 * @param topic          An instance of OKSE Topic object
 * @param publisher      An instance of OKSE Publisher object
 * @param originProtocol The originating protocol name of this message (Cannot be null)
 *///from   w w w.j  av a 2s  . c  om
public Message(@Nonnull String message, String topic, Publisher publisher, @Nonnull String originProtocol) {
    log = Logger.getLogger(Message.class.getName());
    this.publisher = publisher;
    this.topic = topic;
    this.created = LocalDateTime.now();
    this.processed = null;
    this.message = message;
    this.systemMessage = false;
    this.messageID = generateMessageID();
    this.attributes = new HashMap<>();
    this.originProtocol = originProtocol;
}

From source file:com.match_tracker.twitter.TwitterSearch.java

public Integer search(String id, String queryString, ZonedDateTime startTime, ZonedDateTime endTime,
        TweetCallbackListener callback) {
    waitUntilStartIsInThePast(startTime);

    ZonedDateTime postedTimeStart = startTime, postedTimeEnd = startTime;
    LocalDateTime lastLogTime = LocalDateTime.now();

    Integer counter = 0;/*from   w  w w. j  av  a  2 s .  c om*/

    do {
        postedTimeStart = postedTimeEnd;
        postedTimeEnd = calculatePostedTimeEnd(endTime);

        try {
            counter += this.search(constructSearchQuery(queryString, postedTimeStart, postedTimeEnd), callback);
            if (isLongRunningSearch(lastLogTime)) {
                log.log(Level.INFO, "Long-running Twitter search ({0}) has now returned messages: {1}",
                        new Object[] { id, counter });
                lastLogTime = LocalDateTime.now();
            }

            sleep(SEARCH_RATE_DELAY_MS);
        } catch (UnirestException e) {
            log.log(Level.WARNING, "Twitter search failed (UnirestException), retrying in sixty seconds. {0}",
                    e.getMessage());
            postedTimeEnd = postedTimeStart;
            sleep(SEARCH_FAILED_RETRY_DELAY_MS);
        } catch (ParseException e) {
            log.log(Level.WARNING, "Twitter search failed (JsonParseException), retrying in sixty seconds. {0}",
                    e.getMessage());
            postedTimeEnd = postedTimeStart;
            sleep(SEARCH_FAILED_RETRY_DELAY_MS);
        }
    } while (!postedTimeEnd.isEqual(endTime));

    return counter;
}

From source file:com.fns.grivet.service.NamedQueryServiceSprocTest.java

@Test
public void testSuccessfulNamedQueryExecution() throws IOException {
    Resource r = resolver.getResource("classpath:TestSprocQuery.json");
    String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset());
    NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class);
    namedQueryService.create(namedQuery);

    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1));
    params.add("createdTime", tomorrow);
    String result = namedQueryService.get("sproc.getAttributesCreatedBefore", params);
    String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" };
    List<String> actual = JsonPath.given(result).getList("NAME");
    Assertions.assertTrue(actual.size() == 8, "Result should contain 8 attributes");
    Assertions.assertTrue(actual.containsAll(Arrays.asList(expected)));
}