Example usage for org.joda.time LocalDateTime now

List of usage examples for org.joda.time LocalDateTime now

Introduction

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

Prototype

public static LocalDateTime now() 

Source Link

Document

Obtains a LocalDateTime set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:cherry.example.common.foundation.impl.BizDateTimeImpl.java

License:Apache License

@Transactional
@Override/*from  ww w.  jav a2  s .co  m*/
public LocalDateTime now() {
    DateTimeExpression<LocalDateTime> curDtm = currentTimestamp(LocalDateTime.class);
    Tuple tuple = baseQuery(bm).singleResult(curDtm, bm.offsetDay, bm.offsetHour, bm.offsetMinute,
            bm.offsetSecond);
    if (tuple == null) {
        return LocalDateTime.now();
    }
    return tuple.get(curDtm).plusDays(tuple.get(bm.offsetDay)).plusHours(tuple.get(bm.offsetHour))
            .plusMinutes(tuple.get(bm.offsetMinute)).plusSeconds(tuple.get(bm.offsetSecond));
}

From source file:cherry.foundation.async.AsyncFileProcessHandlerImpl.java

License:Apache License

private File createFile(MultipartFile file) throws IOException {
    File tempFile = createTempFile(format(tempPrefix, LocalDateTime.now().toDate()), tempSuffix, tempDir);
    tempFile.deleteOnExit();//  w w w .  j  a v  a  2 s .com
    try {
        try (InputStream in = file.getInputStream(); OutputStream out = new FileOutputStream(tempFile)) {
            ByteStreams.copy(in, out);
            return tempFile;
        }
    } catch (IOException ex) {
        deleteFile(tempFile);
        throw ex;
    }
}

From source file:cherry.foundation.bizdtm.SimpleBizDateTime.java

License:Apache License

@Override
public LocalDateTime now() {
    return LocalDateTime.now();
}

From source file:cherry.spring.common.foundation.impl.BizDateTimeImpl.java

License:Apache License

@Override
public LocalDateTime now() {
    Expression<LocalDateTime> curDtm = currentTimestamp(LocalDateTime.class);
    QBizdatetimeMaster a = new QBizdatetimeMaster("a");
    SQLQuery query = createSqlQuery(a);//from   www .  j a v a  2  s.co  m
    Tuple tuple = queryDslJdbcOperations.queryForObject(query,
            new QTuple(curDtm, a.offsetDay, a.offsetHour, a.offsetMinute, a.offsetSecond));
    if (tuple == null) {
        return LocalDateTime.now();
    }
    return tuple.get(curDtm).plusDays(tuple.get(a.offsetDay)).plusHours(tuple.get(a.offsetHour))
            .plusMinutes(tuple.get(a.offsetMinute)).plusSeconds(tuple.get(a.offsetSecond));
}

From source file:com.axelor.apps.admin.service.ViewDocExportService.java

License:Open Source License

private MetaFile createExportFile(MetaFile metaFile) {

    String date = LocalDateTime.now().toString("ddMMyyyy HH:mm:ss");
    String fileName = "Export " + date + ".xlsx";

    try {/*  w w  w  .  ja v a 2 s  .  c  o  m*/
        File file = File.createTempFile("Export", ".xlsx");
        FileOutputStream outStream = new FileOutputStream(file);
        workBook.write(outStream);
        outStream.close();

        FileInputStream inStream = new FileInputStream(file);
        if (metaFile != null) {
            metaFile.setFileName(fileName);
            metaFile = metaFiles.upload(inStream, metaFile);
        } else {
            metaFile = metaFiles.upload(inStream, fileName);
        }

        inStream.close();

        file.delete();

    } catch (IOException e) {
        e.printStackTrace();
    }

    return metaFile;
}

From source file:com.axelor.apps.admin.web.ViewDocController.java

License:Open Source License

public void export(ActionRequest request, ActionResponse response) {

    ViewDoc viewDoc = request.getContext().asType(ViewDoc.class);

    MetaFile exportFile = viewDoc.getExportFile();
    Boolean panelOnly = viewDoc.getExportOnlyPanel();
    if (exportFile != null && exportFile.getId() != null && !panelOnly) {
        exportFile = metaFileRepo.find(exportFile.getId());
        exportFile = exportService.export(exportFile, false);
    } else {/*from ww w  .  ja va  2  s .  c o  m*/
        exportFile = exportService.export(null, panelOnly);
    }

    response.setValue("exportFile", exportFile);

    response.setValue("exportDate", LocalDateTime.now());

}

From source file:com.axelor.apps.base.service.imports.importer.Importer.java

License:Open Source License

protected String computeFinalWorkspaceName(File data) {
    return String.format("%s-%s", Files.getNameWithoutExtension(data.getName()),
            LocalDateTime.now().toString("yyyyMMdd"));
}

From source file:com.axelor.apps.base.service.message.MessageServiceBaseImpl.java

License:Open Source License

@Override
@Transactional(rollbackOn = { MessagingException.class, IOException.class, Exception.class })
public Message sendByEmail(Message message) throws MessagingException, IOException, AxelorException {

    if (generalService.getGeneral().getActivateSendingEmail()) {
        return super.sendByEmail(message);
    }/*from   ww w. j a  v a 2  s  .co  m*/

    message.setSentByEmail(true);
    message.setStatusSelect(MessageRepository.STATUS_SENT);
    message.setSentDateT(LocalDateTime.now());
    message.setSenderUser(AuthUtils.getUser());

    return messageRepo.save(message);

}

From source file:com.axelor.apps.message.service.MessageServiceImpl.java

License:Open Source License

@Transactional(rollbackOn = Exception.class)
public Message sendToUser(Message message) {

    if (message.getRecipientUser() == null) {
        return message;
    }//from ww w .  java2  s. com

    message.setSenderUser(AuthUtils.getUser());
    log.debug("Sent internal message to user ::: {}", message.getRecipientUser());

    message.setStatusSelect(MessageRepository.STATUS_SENT);
    message.setSentByEmail(false);
    message.setSentDateT(LocalDateTime.now());
    return messageRepo.save(message);

}

From source file:com.axelor.apps.message.service.MessageServiceImpl.java

License:Open Source License

@Transactional(rollbackOn = Exception.class)
public Message sendByMail(Message message) {

    log.debug("Sent mail");
    message.setStatusSelect(MessageRepository.STATUS_SENT);
    message.setSentByEmail(false);/*from   w  w w . j ava2s  . c  om*/
    message.setSentDateT(LocalDateTime.now());
    return messageRepo.save(message);

}