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:com.serphacker.serposcope.db.google.GoogleRankDBIT.java

@Test
public void testSomeMethod() {

    Group grp = new Group(Group.Module.GOOGLE, "grp");
    baseDB.group.insert(grp);//from  w w  w .  j  a  v  a  2s . c  o  m

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

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

    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);

}

From source file:br.ufac.sion.service.InscricaoService.java

public Inscricao salvar(Inscricao inscricao) throws NegocioException {
    LocalDateTime now = LocalDateTime.now();
    infoEmail = new InfoEmail();
    String assunto = "";
    try {//from  w  w w. j av a2s  .  co m
        if (inscricao.getId() != null) {
            if (inscricao.getBoleto() != null) {
                inscricao.getBoleto().setSituacao(SituacaoBoleto.PENDENTE);
            }
            inscricao.setDataInscricao(now);
            inscricao.setStatus(SituacaoInscricao.AGUARDANDO_PAGAMENTO);
            inscricao = em.merge(inscricao);

            assunto = "Alterao da solicitao de inscrio no "
                    + inscricao.getCargoConcurso().getConcurso().getTitulo();
        } else {
            Inscricao insc = pesquisarPorCandidatoEConcurso(inscricao.getCandidato(),
                    inscricao.getCargoConcurso().getConcurso());
            if (insc != null) {
                throw new NegocioException("J foi realizada uma inscrio com o CPF '"
                        + inscricao.getCandidato().getCpf() + "' para o concurso.");
            }
            inscricao.setDataInscricao(now);
            inscricao.setStatus(SituacaoInscricao.AGUARDANDO_PAGAMENTO);
            inscricao = em.merge(inscricao);
            inscricao.setNumero(geraNumeroInscricao(inscricao));
            inscricao = em.merge(inscricao);

            assunto = "Solicitao de inscrio no "
                    + inscricao.getCargoConcurso().getConcurso().getTitulo();
        }

        infoEmail.setPara(inscricao.getCandidato().getUsuario().getEmail());
        infoEmail.setAssunto(assunto);
        infoEmail.setCorpo(geraCorpoEmailSolicitacaoInscricao(inscricao));
        enviaEmailService.processaEnvioDeEmail(infoEmail);

        return inscricao;
    } catch (Exception e) {
        e.printStackTrace();
        throw new NegocioException(e.getMessage());
    }
}

From source file:com.swcguild.capstoneproject.dao.BlogDaoInMemImplTest.java

/**
 * Test of addPost method, of class BlogDaoInMemImpl.
 *///  ww  w.  j  a  v a2 s.  c  om
@Test
public void testAddPost() {
    System.out.println("addPost");
    Post post = new Post("Supergirl", "Clark Kent", "hot new cousin saves city", "super, girl",
            LocalDateTime.now().toString(), "12-30-2015");
    BlogDaoInMemImpl instance = new BlogDaoInMemImpl();
    instance.addPost(post);
    assertEquals(1, instance.getBlogPosts().size());
    Post post2 = new Post();
    instance.addPost(post2);
    assertEquals(2, instance.getBlogPosts().size());
}

From source file:cz.muni.fi.editor.services.api.requests.approve.RequestApproverOrganizationCreate.java

@Override
@Transactional/* w ww.  ja v  a2 s . c o m*/
public void approve(Request request) {
    log.info("Approving request {}", request.getId());
    request.setState(RequestState.ACCEPTED);
    request.setApprover(getPrincipal());
    request.setChangeStateDate(LocalDateTime.now());

    requestDAO.update(request);

    Organization org = organizationDAO.getById(request.getTargetId());
    org.setApproved(true);

    organizationDAO.update(org);

    super.notifyApprove(request);
}

From source file:defaultmethods.SimpleTimeClient.java

public SimpleTimeClient() {
    dateAndTime = LocalDateTime.now();
}

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

@CacheEvict(value = { WallRideCacheConfiguration.USER_CACHE,
        WallRideCacheConfiguration.BLOG_CACHE }, allEntries = true)
public User setup(SetupRequest request) {
    LocalDateTime now = LocalDateTime.now();

    User user = new User();
    user.setLoginId(request.getLoginId());

    StandardPasswordEncoder passwordEncoder = new StandardPasswordEncoder();
    user.setLoginPassword(passwordEncoder.encode(request.getLoginPassword()));

    user.getName().setFirstName(request.getName().getFirstName());
    user.getName().setLastName(request.getName().getLastName());
    user.setEmail(request.getEmail());// ww  w. j av  a  2  s .co m

    user.getRoles().add(User.Role.ADMIN);

    user.setCreatedAt(now);
    user.setUpdatedAt(now);

    user = userRepository.saveAndFlush(user);

    Blog blog = new Blog();
    blog.setCode("default");
    blog.setDefaultLanguage(request.getDefaultLanguage());
    blog.setCreatedAt(now);
    blog.setCreatedBy(user.toString());
    blog.setUpdatedAt(now);
    blog.setUpdatedBy(user.toString());

    BlogLanguage defaultLanguage = new BlogLanguage();
    defaultLanguage.setBlog(blog);
    defaultLanguage.setLanguage(request.getDefaultLanguage());
    defaultLanguage.setTitle(request.getWebsiteTitle());
    defaultLanguage.setCreatedAt(now);
    defaultLanguage.setCreatedBy(user.toString());
    defaultLanguage.setUpdatedAt(now);
    defaultLanguage.setUpdatedBy(user.toString());

    Set<BlogLanguage> blogLanguages = new HashSet<>();
    blogLanguages.add(defaultLanguage);

    for (String language : request.getLanguages()) {
        BlogLanguage blogLanguage = new BlogLanguage();
        blogLanguage.setBlog(blog);
        blogLanguage.setLanguage(language);
        blogLanguage.setTitle(request.getWebsiteTitle());
        blogLanguage.setCreatedAt(now);
        blogLanguage.setCreatedBy(user.toString());
        blogLanguage.setUpdatedAt(now);
        blogLanguage.setUpdatedBy(user.toString());

        blogLanguages.add(blogLanguage);
    }
    blog.setLanguages(blogLanguages);

    blogRepository.saveAndFlush(blog);

    return user;
}

From source file:cz.muni.fi.editor.services.api.requests.approve.RequestApproverOgranizationJoin.java

@Override
@Transactional/*from  w ww .  j  av  a2s. co  m*/
public void approve(Request request) {
    log.info("Approving request {} with operation organization join", request.getId());
    request.setState(RequestState.ACCEPTED);
    request.setApprover(getPrincipal());
    request.setChangeStateDate(LocalDateTime.now());

    requestDAO.update(request);

    Organization org = organizationDAO.getById(request.getTargetId());
    org.getMembers().add(request.getRequestor());

    organizationDAO.update(org);

    super.notifyApprove(request);
}

From source file:ch.aschaefer.udp.DatagramSocketToControlMessageConverter.java

@Override
public ControlMessage convert(DatagramPacket source) {
    return new ControlMessage().timestamp(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now()))
            .hex(toHex(source.getData())).source(source.getSocketAddress().toString())
            .targetHost(source.getAddress().getHostAddress()).targetPort(source.getPort());
}

From source file:org.jspare.server.transaction.TidGeneratorImpl.java

@Override
public String generate() {

    StringBuilder tid = new StringBuilder();
    tid.append(LocalDateTime.now().format(dtf));
    tid.append(StringUtils.leftPad(String.valueOf(ThreadLocalRandom.current().nextLong(MIN, MAX)), 6, "0"));
    tid.append(calculateVerifyDigit(tid.toString()));
    return tid.toString();
}

From source file:org.cyberjos.jcconf2016.node.CloudNodeImpl.java

/**
 * Constructor.//from   w w w  .jav a 2  s  .c  o  m
 */
public CloudNodeImpl() {
    this.nodeName = "Node-" + LocalDateTime.now().format(HazelcastHelper.NAME_FORMATTER);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        logger.info("[{}] Shutdown hook is invoked.", this.nodeName);
        this.deactivate();
        try {
            Thread.currentThread().join();
        } catch (final Exception ex) {
            logger.warn(String.format("[%s] An exception occurs druing shutdown.", this.nodeName), ex);
        }
        Hazelcast.shutdownAll();
    }));
}