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:io.mandrel.spider.SpiderService.java

public Spider add(Spider spider) throws BindException {
    BindingResult errors = Validators.validate(spider);

    if (errors.hasErrors()) {
        errors.getAllErrors().stream().forEach(oe -> log.info(oe.toString()));
        throw new BindException(errors);
    }/*  ww w.  j a  v a 2  s. c  o m*/

    spider.setStatus(SpiderStatuses.INITIATED);
    spider.setCreated(LocalDateTime.now());
    spider = spiderRepository.add(spider);

    updateTimeline(spider, SpiderEventType.SPIDER_CREATED);

    return spider;
}

From source file:org.jgrades.rest.lic.LicenceManagerServiceTest.java

private Licence getExampleLicence() {
    Licence licence = new Licence();
    licence.setUid(122L);/*from   ww  w  . j  av  a  2  s  . c om*/

    Customer customer = new Customer();
    customer.setId(12L);
    customer.setName("XIV LO");

    Product product = new Product();
    product.setName("JG-BASE");
    product.setValidFrom(LocalDateTime.now());
    product.setValidTo(LocalDateTime.now().plusMonths(1));
    product.setVersion("0.4");

    licence.setCustomer(customer);
    licence.setProduct(product);
    return licence;
}

From source file:com.google.refine.model.medadata.ProjectMetadata.java

public void loadFromJSON(JSONObject obj) {
    extractModifiedLocalTime(obj);//ww w  . j  a  v  a 2s .c om

    this._name = JSONUtilities.getString(obj, "name", "<Error recovering project name>");
    this._password = JSONUtilities.getString(obj, "password", "");

    this._encoding = JSONUtilities.getString(obj, "encoding", "");
    this._encodingConfidence = JSONUtilities.getInt(obj, "encodingConfidence", 0);

    this._creator = JSONUtilities.getString(obj, "creator", "");
    this._contributors = JSONUtilities.getString(obj, "contributors", "");
    this._subject = JSONUtilities.getString(obj, "subject", "");
    this._description = JSONUtilities.getString(obj, "description", "");
    this._rowCount = JSONUtilities.getInt(obj, "rowCount", 0);

    this.title = JSONUtilities.getString(obj, "title", "");
    this.homepage = JSONUtilities.getString(obj, "homepage", "");
    this.image = JSONUtilities.getString(obj, "image", "");
    this.license = JSONUtilities.getString(obj, "license", "");
    this.version = JSONUtilities.getString(obj, "version", "");

    this._tags = JSONUtilities.getStringArray(obj, "tags");

    if (obj.has("preferences") && !obj.isNull("preferences")) {
        try {
            this._preferenceStore.load(obj.getJSONObject("preferences"));
        } catch (JSONException e) {
            logger.error(ExceptionUtils.getStackTrace(e));
        }
    }

    if (obj.has("expressions") && !obj.isNull("expressions")) { // backward compatibility
        try {
            ((TopList) this._preferenceStore.get("scripting.expressions"))
                    .load(obj.getJSONArray("expressions"));
        } catch (JSONException e) {
            logger.error(ExceptionUtils.getStackTrace(e));
        }
    }

    if (obj.has("customMetadata") && !obj.isNull("customMetadata")) {
        try {
            JSONObject obj2 = obj.getJSONObject("customMetadata");

            Iterator<String> keys = obj2.keys();
            while (keys.hasNext()) {
                String key = keys.next();
                Object value = obj2.get(key);
                if (value != null && value instanceof Serializable) {
                    this._customMetadata.put(key, (Serializable) value);
                }
            }
        } catch (JSONException e) {
            logger.error(ExceptionUtils.getStackTrace(e));
        }
    }

    if (obj.has("importOptionMetadata") && !obj.isNull("importOptionMetadata")) {
        try {
            JSONArray jsonArray = obj.getJSONArray("importOptionMetadata");
            this._importOptionMetadata = jsonArray;
        } catch (JSONException e) {
            logger.error(ExceptionUtils.getStackTrace(e));
        }
    }

    if (obj.has(PreferenceStore.USER_METADATA_KEY) && !obj.isNull(PreferenceStore.USER_METADATA_KEY)) {
        try {
            JSONArray jsonArray = obj.getJSONArray(PreferenceStore.USER_METADATA_KEY);
            this._userMetadata = jsonArray;
        } catch (JSONException e) {
            logger.error(ExceptionUtils.getStackTrace(e));
        }
    }

    this.written = LocalDateTime.now(); // Mark it as not needing writing until modified

}

From source file:org.ow2.proactive.workflow_catalog.rest.service.WorkflowRevisionServiceTest.java

@Test
public void testDeleteWorkflowWith1Revision() throws Exception {
    WorkflowRevision wfRev = new WorkflowRevision(DUMMY_ID, EXISTING_ID, "WR-TEST", "WR-PROJ-NAME",
            LocalDateTime.now(), null, Lists.newArrayList(), Lists.newArrayList(),
            getWorkflowAsByteArray("workflow.xml"));
    Workflow workflow1Rev = newMockedWorkflow(EXISTING_ID, mockedBucket, new TreeSet<WorkflowRevision>() {
        {/*  w w  w.j  a  v  a2 s  .co  m*/
            add(wfRev);
        }
    }, EXISTING_ID);
    when(workflowRepository.findOne(EXISTING_ID)).thenReturn(workflow1Rev);
    when(workflowRepository.getMostRecentWorkflowRevision(mockedBucket.getId(), workflow1Rev.getId()))
            .thenReturn(wfRev);
    workflowRevisionService.delete(mockedBucket.getId(), EXISTING_ID, Optional.empty());
    verify(workflowRepository, times(1)).getMostRecentWorkflowRevision(EXISTING_ID, EXISTING_ID);
    verify(workflowRepository, times(1)).delete(workflow1Rev);
}

From source file:fi.csc.emrex.smp.ThymeController.java

private String generatePersonalLogLine(HttpServletRequest httpRequest, Person person, String source)
        throws Exception {
    String personalLogLine = source + "\t" + person.getFullName();
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    LocalDateTime startTime = (LocalDateTime) context.getSession().getAttribute("sessionStartTime");
    if (startTime == null) {
        startTime = LocalDateTime.now();
    }//w  ww . j a  v  a  2  s  . co  m
    personalLogLine += "\t" + startTime.format(dateFormatter);

    String url = httpRequest.getHeader("Referer");
    String NCPDomain = "";
    if (url != null) {
        URI uri = new URI(url);
        NCPDomain = uri.getHost();
    }

    personalLogLine += "\t" + NCPDomain;
    personalLogLine += "\t" + httpRequest.getParameter("returnCode");
    return personalLogLine;
}

From source file:com.google.refine.model.medadata.ProjectMetadata.java

private void extractModifiedLocalTime(JSONObject obj) {
    String modified = JSONUtilities.getString(obj, "modified", LocalDateTime.now().toString());
    if (modified.endsWith("Z")) {
        this._modified = ParsingUtilities.stringToDate(modified).toLocalDateTime();
    } else {/* w  w  w.  j  a  v  a  2 s  .c  o  m*/
        this._modified = ParsingUtilities.stringToLocalDate(modified);
    }
}

From source file:org.wallride.service.UserService.java

@CacheEvict(value = WallRideCacheConfiguration.USER_CACHE, allEntries = true)
public User updatePassword(PasswordUpdateRequest request, AuthorizedUser updatedBy) {
    User user = userRepository.findOneForUpdateById(request.getUserId());
    if (user == null) {
        throw new IllegalArgumentException("The user does not exist");
    }//  www .j a va  2  s.  c  o  m
    PasswordEncoder passwordEncoder = new StandardPasswordEncoder();
    user.setLoginPassword(passwordEncoder.encode(request.getPassword()));
    user.setUpdatedAt(LocalDateTime.now());
    user.setUpdatedBy(updatedBy.toString());
    return userRepository.saveAndFlush(user);
}