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.typemanager.TypeServiceImpl.java

private void createBackup(Path target) throws IOException {
    if (Files.exists(target)) {
        String newName = getBaseName(target.getFileName().toString()) + "."
                + LocalDateTime.now().format(formatter) + ".xml";

        Files.move(target, target.resolveSibling(newName));

        Files.createFile(target);
    }/*  www  .  j  av  a2 s . co m*/
}

From source file:cz.muni.fi.editor.database.test.NotificationDAOTest.java

@Test
public void update() {
    Notification n = notificationDAO.getById(18L);
    n.setSeenDate(LocalDateTime.now());

    notificationDAO.update(n);/*ww w. jav  a2  s .  co m*/

    Assert.assertNotNull(notificationDAO.getById(18L).getSeenDate());
}

From source file:org.objectspace.rfid.library.inventory.InventoryCallback.java

/**
 * @throws ClassNotFoundException/*from ww  w .  j a  va2  s. com*/
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws SQLException
 * 
 */
public InventoryCallback(InventoryDialog dlg, AbstractConfiguration config)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
    this.config = config;
    this.dlg = dlg;
    sessionName = LocalDateTime.now().toString();

    if (conn == null) {

        if (config != null) {
            String driver = config.getString("database.driver");
            String dsn = config.getString("database.dsn");

            if (driver != null && dsn != null) {
                Class.forName(driver).newInstance();
                conn = DriverManager.getConnection(dsn);
                conn.setAutoCommit(true);
            }
        }
    }

    uidList = new TreeSet<String>();

    String insertSQL = "REPLACE INTO `rfid`.`inventory` "
            + "(`uid`, `version`, `usagetype`, `parts`, `partno`, `itemid`, `country`, `isil`, `inventorytime`"
            + ", `marker`, `sessionname`, `raw`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?, ?)";
    stmt = conn.prepareStatement(insertSQL);

    String selectsql = "SELECT signatur FROM code_sig WHERE barcode=?";
    stmt2 = conn.prepareStatement(selectsql);
}

From source file:io.hawkcd.agent.components.taskexecutor.executors.UploadArtifactExecutor.java

@Override
public Task executeTask(Task task, StringBuilder report, WorkInfo workInfo) {
    UploadArtifactTask taskDefinition = (UploadArtifactTask) task.getTaskDefinition();

    this.updateTask(task, TaskStatus.PASSED, LocalDateTime.now(), null);

    String uploadingMessage = String.format("Start uploading artifact source: %s ", taskDefinition.getSource());
    LOGGER.debug(uploadingMessage);//from w w  w. ja v  a  2 s .co m
    ReportAppender.appendInfoMessage(uploadingMessage, report);

    String pathToFile = AgentConfiguration.getInstallInfo().getAgentSandbox() + File.separator + "Pipelines"
            + File.separator + workInfo.getPipelineDefinitionName() + File.separator
            + taskDefinition.getSource();
    //        if (!taskDefinition.getSource().isEmpty()) {
    //            pathToFile = pathToFile + File.separator + taskDefinition.getSource();
    //        }

    String fullPath = this.fileManagementService.pathCombine(pathToFile);
    String rootPath = this.fileManagementService.getRootPath(fullPath);
    String wildCardPattern = this.fileManagementService.getPattern(rootPath, fullPath);

    if (rootPath.isEmpty()) {
        return this.nullProcessing(report, task,
                String.format("%s is Non-existent source.", taskDefinition.getSource()));
    }

    List<File> files = this.fileManagementService.getFiles(fullPath, wildCardPattern);

    if (files.size() == 0) {
        return this.nullProcessing(report, task, String.format("Error in getting files in %s", fullPath));
    }

    File zipFile = this.fileManagementService
            .generateUniqueFile(AgentConfiguration.getInstallInfo().getAgentTempDirectoryPath(), "zip");

    String errorMessage = this.fileManagementService.zipFiles(zipFile.getPath(), files, rootPath, true);

    if (errorMessage != null) {
        zipFile.delete();
        return this.nullProcessing(report, task, "Error occurred in zipping files!");
    }

    String executionFolder = String.valueOf(workInfo.getPipelineExecutionID());
    UploadArtifactInfo uploadArtifactInfo = new UploadArtifactInfo(zipFile, taskDefinition.getDestination());
    String folderPath = String.format(ConfigConstants.SERVER_CREATE_ARTIFACT_API_ADDRESS,
            workInfo.getPipelineDefinitionName(), executionFolder);
    AgentConfiguration.getInstallInfo().setCreateArtifactApiAddress(
            String.format("%s/%s", AgentConfiguration.getInstallInfo().getServerAddress(), folderPath));

    String destination = null;
    try {
        destination = URLEncoder.encode(taskDefinition.getDestination(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();

    }

    String requestSource = this.fileManagementService
            .urlCombine(AgentConfiguration.getInstallInfo().getCreateArtifactApiAddress()) + "/upload-artifact"
            + "?destination=" + destination;
    WebResource webResource = this.restClient.resource(requestSource);
    InputStream targetStream = null;
    try {
        targetStream = FileUtils.openInputStream(zipFile);
    } catch (IOException e) {
        e.printStackTrace();
    }

    ClientResponse response = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class,
            targetStream);

    if (response.getStatus() != 200) {
        zipFile.delete();
        return this.nullProcessing(report, task, String
                .format("Error occurred in server response! Returned status code: %s", response.getStatus()));
    }

    zipFile.delete();

    this.updateTask(task, TaskStatus.PASSED, null, LocalDateTime.now());

    return task;
}

From source file:com.example.InitialModelConfig.java

@SuppressWarnings("unchecked")
public InitialModelConfig(final IdGenerator idGenerator) {
    this.idGenerator = idGenerator;
    final MutableList<UserAccount> users = Lists.mutable.of(
            UserAccount.of(idGenerator.generateLong(), "foo", "foo-pass", "FOO", Role.USER),
            UserAccount.of(idGenerator.generateLong(), "bar", "bar-pass", "BAR[ADMIN]", Role.USER, Role.ADMIN,
                    Role.BETA_USER),
            UserAccount.of(idGenerator.generateLong(), "baz", "baz-pass", "BAZ[beta]", Role.USER,
                    Role.BETA_USER),
            UserAccount.of(idGenerator.generateLong(), "qux", "qux-pass", "qux-pass", Role.USER));
    userAccounts = users.groupByUniqueKey(UserAccount::getLoginId);
    final MutableList<TalkRoom> talkRoomList = Lists.mutable.of(
            TalkRoom.of(idGenerator.generateLong(), "all users", "talk room which contains all users."),
            TalkRoom.of(idGenerator.generateLong(), "admins", "admins"),
            TalkRoom.of(idGenerator.generateLong(), "beta users", "beta users"));
    talkRoomList.forEach(talkRoom -> talkRooms.put(talkRoom.getId(), talkRoom));
    final LocalDateTime now = LocalDateTime.now();
    talkRoomMembers = Lists.mutable/*w w  w .  ja v a2 s  . c  om*/
            .of(pair(0, IntLists.mutable.of(0, 1, 2, 3)), pair(1, IntLists.mutable.of(1)),
                    pair(2, IntLists.mutable.of(1, 2)))
            .collect(p -> Tuples.pair(talkRoomList.get(p.getOne()), p.getTwo().collect(users::get)))
            .flatCollect(
                    p -> p.getTwo().collect(ua -> new TalkRoomMember(p.getOne().getId(), ua.getId(), now)));
}

From source file:com.serphacker.serposcope.db.google.GoogleRankDBBench.java

@Test
public void testBenchmark() {

    Group grp = new Group(Group.Module.GOOGLE, "grp");
    baseDB.group.insert(grp);//www. ja va2  s .co  m

    GoogleSearch search = new GoogleSearch("keyword");
    googleDB.search.insert(Arrays.asList(search), grp.getId());

    GoogleTarget target = new GoogleTarget(grp.getId(), "name", PatternType.REGEX, "pattern");
    googleDB.target.insert(Arrays.asList(target));

    long _time = System.currentTimeMillis();
    for (int i = 0; i < 100000; i++) {
        Run run = new Run(Run.Mode.CRON, Group.Module.GOOGLE, LocalDateTime.now().withNano(0));
        baseDB.run.insert(run);

        GoogleRank rank = new GoogleRank(run.getId(), grp.getId(), target.getId(), search.getId(), 1, 2, "url");
        googleDB.rank.insert(rank);

        rank = new GoogleRank(run.getId(), grp.getId(), target.getId(), search.getId(), 2, 3, "url");
        googleDB.rank.insert(rank);
    }
    System.out.println(DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - _time));

}

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

@CacheEvict(value = { WallRideCacheConfiguration.ARTICLE_CACHE,
        WallRideCacheConfiguration.PAGE_CACHE }, allEntries = true)
public Tag createTag(TagCreateRequest request, AuthorizedUser authorizedUser) {
    Tag duplicate = tagRepository.findOneByNameAndLanguage(request.getName(), request.getLanguage());
    if (duplicate != null) {
        throw new DuplicateNameException(request.getName());
    }/*from   w  ww .java  2  s  . c  om*/

    Tag tag = new Tag();
    LocalDateTime now = LocalDateTime.now();

    tag.setName(request.getName());
    tag.setLanguage(request.getLanguage());

    tag.setCreatedAt(now);
    tag.setCreatedBy(authorizedUser.toString());
    tag.setUpdatedAt(now);
    tag.setUpdatedBy(authorizedUser.toString());
    return tagRepository.saveAndFlush(tag);
}

From source file:io.yields.math.framework.kpi.ScoreDAO.java

private static File getRootFolder() {
    if (scoreFolder == null) {
        File yieldsFolder = new File(System.getProperty(YIELDS_SCORE_PATH, getTempDirectoryPath()),
                FOLDER_NAME);//from w  w  w  .  j a  v a 2s.c o m
        scoreFolder = new File(yieldsFolder, DATE_TIME_FORMATTER.format(LocalDateTime.now()));
    }
    return scoreFolder;
}

From source file:com.serphacker.serposcope.models.base.Run.java

public long getRemainingTimeMs() {
    return getRemainingTimeMs(LocalDateTime.now());
}

From source file:de.steilerdev.myVerein.server.model.Message.java

public Message(String content, User sender, Division group) {
    this(content, LocalDateTime.now(), sender, group);
}