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:cz.muni.fi.editor.services.api.requests.decline.RequestDeclinerOrganizationCreate.java

@Override
@Transactional/*from w  ww . j  a  v a  2 s  .com*/
public void decline(Request request) {
    request.setChangeStateDate(LocalDateTime.now());
    request.setApprover(getPrincipal());
    request.setState(RequestState.REJECTED);

    requestDAO.update(request);

    organizationDAO.delete(request.getTargetId());
}

From source file:org.openapis.example.manual.AbstractResource.java

@POST
public T create(T entity) {
    if (entity instanceof Auditable) {
        LocalDateTime now = LocalDateTime.now();
        String user = getUserName();
        Auditable auditable = (Auditable) entity;
        auditable.setCreatedBy(user);//from   ww w  .j  a  va 2  s.  c  om
        auditable.setCreatedDate(now);
        auditable.setModifiedBy(user);
        auditable.setModifiedDate(now);
    }

    return service.insert(entity);
}

From source file:org.compbox.actionbackup.ChronoBackupper.java

public File getFileName() {
    return this.destDirectory.resolve(LocalDateTime.now().format(dtf)).toFile();

}

From source file:com.caiyunworks.crm.business.aop.AuditAdvice.java

@Before("@annotation(com.caiyunworks.crm.persist.aop.Auditable)")
public void audit(JoinPoint joinPoint) {
    if (logger.isInfoEnabled()) {
        logger.info("auditable model is going to be persisted");
    }/*  w  ww.  j  a v a2s  .  c o  m*/
    Object[] args = joinPoint.getArgs();
    if (ArrayUtils.isNotEmpty(args)) {
        Object arg = args[0];
        if (null != arg && arg instanceof GenericModel) {
            GenericModel model = (GenericModel) arg;
            LocalDateTime now = LocalDateTime.now();

            model.setCreatedBy(1);
            model.setCreationTime(now);

            model.setLastUpdatedBy(1);
            model.setLastUpdateTime(now);

            Integer versionNumber = model.getVersionNumber();
            if (null == versionNumber) {
                versionNumber = 1;
            } else {
                versionNumber += 1;
            }
            model.setVersionNumber(versionNumber);
        }
    }
}

From source file:eu.over9000.skadi.Main.java

private static void printStartupInfo(final String[] args) {
    LOGGER.info("################################################################################");
    LOGGER.info("TIME:    " + LocalDateTime.now().toString());
    LOGGER.info("OS:      " + SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION + " " + SystemUtils.OS_ARCH);
    LOGGER.info("JAVA:    " + SystemUtils.JAVA_VERSION);
    LOGGER.info(//  w  ww.  j a  v a 2s .c o  m
            "         " + SystemUtils.JAVA_RUNTIME_NAME + " <build " + SystemUtils.JAVA_RUNTIME_VERSION + ">");
    LOGGER.info("VM:      " + SystemUtils.JAVA_VM_NAME + " <build" + SystemUtils.JAVA_VM_VERSION + ", "
            + SystemUtils.JAVA_VM_INFO + ">");
    LOGGER.info("VM-ARGS: " + ManagementFactory.getRuntimeMXBean().getInputArguments());
    if (VersionRetriever.isLocalInfoAvailable()) {
        LOGGER.info("SKADI:   " + VersionRetriever.getLocalVersion() + " " + VersionRetriever.getLocalBuild()
                + " " + VersionRetriever.getLocalTimestamp());
    } else {
        LOGGER.info("SKADI:   " + "No local version info available");
    }
    LOGGER.info("ARGS:    " + Arrays.asList(args));
    LOGGER.info("################################################################################");
}

From source file:de.olivergierke.spring4.web.OrderController.java

@RequestMapping("/orders/{id}")
ResponseEntity<OrderResourceModel> showOrder(@PathVariable Long id) {

    // /customers/6

    URI uri = fromMethodCall(controller(CustomerController.class).customers(6L)).build().toUri();

    // URI uri = fromMethodCall(controller(CustomerController.class).customers(6L)).build().toUri();
    return new ResponseEntity<>(new OrderResourceModel(LocalDateTime.now(), uri), HttpStatus.OK);
}

From source file:io.mandrel.metrics.MetricsService.java

public Timeserie serie(String name) {
    Timeserie serie = metricsRepository.serie(name);

    LocalDateTime now = LocalDateTime.now();
    LocalDateTime minus4Hours = now.withMinute(0).withSecond(0).withNano(0).minusHours(4);

    LocalDateTime firstTime = CollectionUtils.isNotEmpty(serie) && serie.first() != null
            && serie.first().getTime().isBefore(minus4Hours) ? serie.first().getTime() : minus4Hours;
    LocalDateTime lastTime = now;

    Set<Data> results = LongStream.range(0, Duration.between(firstTime, lastTime).toMinutes())
            .mapToObj(minutes -> firstTime.plusMinutes(minutes)).map(time -> Data.of(time, Long.valueOf(0)))
            .collect(TreeSet::new, TreeSet::add, (left, right) -> {
                left.addAll(right);/*  ww w  .  j  a  v  a 2  s.c  om*/
            });

    Timeserie serieWithBlank = new Timeserie();
    serieWithBlank.addAll(results);
    serieWithBlank.addAll(serie);

    return serieWithBlank;
}

From source file:org.lecture.model.SourceContainer.java

public SourceContainer(String userId, String taskId) {
    this.userId = userId;
    this.taskId = taskId;
    this.sources = new HashMap<>();
    this.submissionDate = LocalDateTime.now();
    this.compilationReport = new CompilationReport();
}

From source file:com.bekwam.mavenpomupdater.ErrorLogDelegate.java

public void log(String fileName, String message) {

    if (log.isDebugEnabled()) {
        log.debug("[LOG] fileName=" + fileName + ", message=" + message);
    }//from ww  w  .  j  a  va2 s. co m

    LocalDateTime now = LocalDateTime.now();
    String logTime = now.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);

    tblErrors.getItems().add(new ErrorLogEntry(logTime, fileName, message));
}

From source file:org.darkware.wpman.data.WPCronHook.java

public boolean isWaiting() {
    return (this.nextRun.isBefore(LocalDateTime.now()));
}