Example usage for java.time LocalDateTime of

List of usage examples for java.time LocalDateTime of

Introduction

In this page you can find the example usage for java.time LocalDateTime of.

Prototype

public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second) 

Source Link

Document

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

Usage

From source file:at.ac.tuwien.qse.sepm.dao.impl.JDBCJourneyDAOTest.java

@Test(expected = ValidationException.class)
@WithData//from   www  .j av  a2 s. c o  m
public void updateWithIdNullShouldThrow() throws DAOException, ValidationException {
    journeyDAO.update(new Journey(null, "Vienna", LocalDateTime.of(2010, 3, 6, 0, 0, 0),
            LocalDateTime.of(2015, 3, 6, 0, 0, 0)));
}

From source file:at.ac.tuwien.qse.sepm.dao.impl.JDBCJourneyDAOTest.java

@Test
@WithData/*  ww w  .j  ava  2s.co  m*/
public void updateWithValidNameShouldUpdate() throws DAOException, ValidationException {
    journeyDAO.update(new Journey(1, "Vienna", LocalDateTime.of(2010, 3, 6, 0, 0, 0),
            LocalDateTime.of(2015, 3, 6, 0, 0, 0)));
    assertThat(journeyDAO.getByID(1).getName(), equalTo("Vienna"));
}

From source file:org.wallride.web.controller.guest.article.ArticleIndexController.java

@RequestMapping("/{year:[0-9]{4}}/{month:[0-9]{2}}/{day:[0-9]{2}}")
public String day(@PathVariable int year, @PathVariable int month, @PathVariable int day,
        @PageableDefault(10) Pageable pageable, BlogLanguage blogLanguage, HttpServletRequest servletRequest,
        Model model) {//from  w  w w. ja  va  2s . c om
    ArticleSearchForm form = new ArticleSearchForm() {
    };
    form.setLanguage(blogLanguage.getLanguage());
    form.setDateFrom(LocalDateTime.of(year, month, day, 0, 0, 0));
    form.setDateTo(LocalDateTime.of(year, month, day, 23, 59, 59));

    Page<Article> articles = articleService.getArticles(form.toArticleSearchRequest(), pageable);
    model.addAttribute("articles", articles);
    model.addAttribute("pageable", pageable);
    model.addAttribute("pagination", new Pagination<>(articles, servletRequest));
    return "article/index";
}

From source file:net.sf.gazpachoquest.dbpopulator.DBPopulator.java

public void populateJavaPerformanceSurvey(Set<UserDTO> respondents) {
    QuestionnaireDefinitionDTO questionnaireDefinition = javaPerformanceSurveyCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    ResearchDTO research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("Tracked survey: " + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);
    Integer researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }//from www  . j a v a2  s.  co  m
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous Survey: " + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();

    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);

}

From source file:net.sf.gazpachoquest.dbpopulator.DBPopulator.java

public void populateForJUnitTest(Set<UserDTO> respondents) {
    QuestionnaireDefinitionDTO questionnaireDefinition = demoSurveyCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    ResearchDTO research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New private Questionnaire " + questionnaireDefinition.getLanguageSettings().getTitle()
                    + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);
    Integer researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }//from w  w w. j  a  va2  s  .  c  om
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("New open Questionnaire " + questionnaireDefinition.getLanguageSettings().getTitle()
                    + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();

    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);
}

From source file:net.sf.gazpachoquest.dbpopulator.DBPopulator.java

public void populateForFullDemo(Set<UserDTO> respondents) {
    // No Randomization enabled
    QuestionnaireDefinitionDTO questionnaireDefinition = sampleQuizCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    ResearchDTO research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);

    Integer researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }/*from w w w.  j  av a  2s  .c  om*/
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);

    questionnaireDefinition = sampleQuizCreator.create();
    questionnaireDefinition.setRenderingMode(RenderingMode.ALL_IN_ONE);
    questionnaireDefinition = questionnaireDefinitionEditorFacade.save(questionnaireDefinition);

    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);

    // Question Randomization Enabled
    questionnaireDefinition = sampleQuizCreator.create();
    questionnaireDefinition.setQuestionsPerPage(1);
    questionnaireDefinition.setRandomizationStrategy(RandomizationStrategy.QUESTIONS_RANDOMIZATION);
    questionnaireDefinition = questionnaireDefinitionEditorFacade.save(questionnaireDefinition);

    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);

    researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    research = researchFacade.save(research);

    // Groups Randomization Enabled
    questionnaireDefinition = sampleQuizCreator.create();
    questionnaireDefinition.setRandomizationStrategy(RandomizationStrategy.SECTIONS_RANDOMIZATION);
    questionnaireDefinition = questionnaireDefinitionEditorFacade.save(questionnaireDefinition);

    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);

    researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    researchFacade.save(research);

    // First Group Randomization Enabled
    questionnaireDefinition = sampleQuizCreator.create();
    SectionDTO firstSection = questionnaireDefinition.getSections().get(0);
    firstSection.setRandomizationEnabled(true);
    questionnaireDefinitionEditorFacade.save(firstSection);

    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);

    researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    researchFacade.save(research);

    questionnaireDefinition = fastFoodSurveyCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("New customer satisfation survey " + questionnaireDefinition.getLanguageSettings().getTitle()
                    + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    researchFacade.save(research);

    questionnaireDefinition = javaPerformanceSurveyCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Java Performance Survey " + questionnaireDefinition.getLanguageSettings().getTitle()
                    + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    researchFacade.save(research);

}

From source file:at.ac.tuwien.qse.sepm.service.impl.ClusterServiceTest.java

@Test
@WithData/*www  .ja  v a 2  s .c  o m*/
public void test_multiple_cluster() throws ServiceException, DAOException {
    Journey usaJourney = getDenverJourney();

    photosExtended.add(photoDAO.create(new Photo(6, Paths.get("6.jpg"),
            makeMetaSanFrancisco(LocalDateTime.of(2005, 9, 12, 0, 0, 0), 37.77, -122.42))));
    photosExtended.add(photoDAO.create(new Photo(7, Paths.get("7.jpg"),
            makeMetaSanFrancisco(LocalDateTime.of(2005, 9, 12, 0, 0, 0), 37.78, -122.419))));

    assertThat(clusterService.getAllJourneys().size(), is(2));
    List<Place> places = clusterService.clusterJourney(usaJourney);
    assertThat(clusterService.getAllJourneys().size(), is(3));
    assertThat(clusterService.getAllJourneys(), hasItem(usaJourney));

    assertThat(places.size(), is(2));
    assertThat(places.stream().filter(p -> p.getCity().equals("San Francisco")).count() == 1, is(Boolean.TRUE));
    assertThat(places.stream().filter(p -> p.getCity().equals("Denver")).count() == 1, is(Boolean.TRUE));
}

From source file:msi.gama.util.GamaDate.java

private static LocalDateTime computeFromList(final IScope scope, final IList<?> vals) {
    int year = 0, month = 1, day = 1, hour = 0, minute = 0, second = 0;
    final int size = vals.size();
    if (size > 0) {
        year = Cast.asInt(scope, vals.get(0));
        if (size > 1) {
            month = Cast.asInt(scope, vals.get(1));
            if (size > 2) {
                day = Cast.asInt(scope, vals.get(2));
                if (size > 3) {
                    hour = Cast.asInt(scope, vals.get(3));
                    if (size > 4) {
                        minute = Cast.asInt(scope, vals.get(4));
                        if (size > 5) {
                            second = Cast.asInt(scope, vals.get(5));
                        }/*ww w  .  j a  v  a 2s.c  o  m*/
                    }
                }
            }
        }
    }
    return LocalDateTime.of(year, month, day, hour, minute, second);
}

From source file:net.sf.gazpachoquest.dbpopulator.DBPopulator.java

public void populateForDemo(Set<UserDTO> respondents) {
    QuestionnaireDefinitionDTO questionnaireDefinition = sampleQuizCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);
    Set<QuestionnaireDefinitionDTO> questionnairDefinitions = new HashSet<>();
    questionnairDefinitions.add(questionnaireDefinition);

    ResearchDTO research = ResearchDTO.with().type(ResearchAccessType.BY_INVITATION)
            .name("New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);

    Integer researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }/* w ww  .ja  v a2  s .co m*/
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("Anonymous New Quiz" + questionnaireDefinition.getLanguageSettings().getTitle() + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);

    research = researchFacade.save(research);

    researchId = research.getId();

    for (UserDTO respondent : respondents) {
        researchFacade.addRespondent(researchId, respondent);
    }
    researchFacade.changeStatus(researchId, EntityStatus.CONFIRMED);

    questionnaireDefinition = fastFoodSurveyCreator.create();
    asignDefaultMailTemplate(questionnaireDefinition);
    questionnaireDefinitionEditorFacade.confirm(questionnaireDefinition);
    questionnairDefinitions = new HashSet<>();
    questionnairDefinitions.add(questionnaireDefinition);

    research = ResearchDTO.with().type(ResearchAccessType.OPEN_ACCESS)
            .name("New customer satisfation survey " + questionnaireDefinition.getLanguageSettings().getTitle()
                    + " started")
            .startDate(LocalDateTime.now()).expirationDate(LocalDateTime.of(2015, 12, 31, 12, 0, 0)).build();
    research.setQuestionnaireDefinition(questionnaireDefinition);
    researchFacade.save(research);
}

From source file:no.imr.stox.functions.acoustic.PgNapesIO.java

public static void convertPgNapesToLuf20(String path, String fileName, String outFileName) {
    try {/*ww  w  . j a v a 2  s  . co  m*/
        List<String> acList = Files.readAllLines(Paths.get(path + "/" + fileName + ".txt"));
        List<String> acVList = Files.readAllLines(Paths.get(path + "/" + fileName + "Values.txt"));
        if (acList.isEmpty() || acVList.isEmpty()) {
            return;
        }
        acList.remove(0);
        acVList.remove(0);
        List<DistanceBO> dList = acList.stream().map(s -> {
            DistanceBO d = new DistanceBO();
            String[] str = s.split("\t", 14);
            d.setNation(str[0]);
            d.setPlatform(str[1]);
            d.setCruise(str[2]);
            d.setLog_start(Conversion.safeStringtoDoubleNULL(str[3]));
            d.setStart_time(Date.from(LocalDateTime.of(Conversion.safeStringtoIntegerNULL(str[4]),
                    Conversion.safeStringtoIntegerNULL(str[5]), Conversion.safeStringtoIntegerNULL(str[6]),
                    Conversion.safeStringtoIntegerNULL(str[7]), Conversion.safeStringtoIntegerNULL(str[8]), 0)
                    .toInstant(ZoneOffset.UTC)));
            d.setLat_start(Conversion.safeStringtoDoubleNULL(str[9]));
            d.setLon_start(Conversion.safeStringtoDoubleNULL(str[10]));
            d.setIntegrator_dist(Conversion.safeStringtoDoubleNULL(str[11]));
            FrequencyBO freq = new FrequencyBO();
            d.getFrequencies().add(freq);
            freq.setTranceiver(1); // implicit in pgnapes
            freq.setUpper_interpret_depth(0d);
            freq.setUpper_integrator_depth(0d);
            freq.setDistance(d);
            freq.setFreq(Conversion.safeStringtoIntegerNULL(str[12]));
            freq.setThreshold(Conversion.safeStringtoDoubleNULL(str[13]));
            return d;
        }).collect(Collectors.toList());
        // Fill in sa values
        acVList.forEach(s -> {
            String[] str = s.split("\t", 11);
            String cruise = str[2];
            Double log = Conversion.safeStringtoDoubleNULL(str[3]);
            Integer year = Conversion.safeStringtoIntegerNULL(str[4]);
            Integer month = Conversion.safeStringtoIntegerNULL(str[5]);
            Integer day = Conversion.safeStringtoIntegerNULL(str[6]);
            if (log == null || year == null || month == null || day == null) {
                return;
            }
            DistanceBO d = dList.parallelStream().filter(di -> {
                if (di.getCruise() == null || di.getLog_start() == null || di.getStart_time() == null) {
                    return false;
                }
                LocalDate ld = di.getStart_time().toInstant().atZone(ZoneOffset.UTC).toLocalDate();
                return cruise.equals(di.getCruise()) && log.equals(di.getLog_start())
                        && year.equals(ld.getYear()) && month.equals(ld.getMonthValue())
                        && day.equals(ld.getDayOfMonth());
            }).findFirst().orElse(null);
            if (d == null) {
                return;
            }
            FrequencyBO freq = d.getFrequencies().get(0);

            String species = str[7];
            Integer acocat = PgNapesEchoConvert.getAcoCatFromPgNapesSpecies(species);
            Double chUppDepth = Conversion.safeStringtoDoubleNULL(str[8]);
            Double chLowDepth = Conversion.safeStringtoDoubleNULL(str[9]);
            Double sa = Conversion.safeStringtoDoubleNULL(str[10]);
            if (acocat == null || sa == null || sa == 0d || chLowDepth == null || chUppDepth == null) {
                return;
            }
            if (d.getPel_ch_thickness() == null) {
                d.setPel_ch_thickness(chLowDepth - chUppDepth);
            }
            Integer ch = (int) (chLowDepth / d.getPel_ch_thickness() + 0.5);
            SABO sabo = new SABO();
            sabo.setFrequency(freq);
            freq.getSa().add(sabo);
            sabo.setAcoustic_category(acocat + "");
            sabo.setCh_type("P");
            sabo.setCh(ch);
            sabo.setSa(sa);
        });
        // Calculate number of pelagic channels

        /*dList.stream().forEach(d -> {
        FrequencyBO f = d.getFrequencies().get(0);
        Integer minCh = f.getSa().stream().map(SABO::getCh).min(Integer::compare).orElse(null);
        Integer maxCh = f.getSa().stream().map(SABO::getCh).max(Integer::compare).orElse(null);
        if (maxCh != null && minCh != null) {
            f.setNum_pel_ch(maxCh - minCh + 1);
        }
        });*/

        if (dList.isEmpty()) {
            return;
        }
        DistanceBO d = dList.get(0);
        String cruise = d.getCruise();
        String nation = d.getNation();
        String pl = d.getPlatform();
        ListUser20Writer.export(cruise, nation, pl, path + "/" + cruise + outFileName + ".xml", dList);

    } catch (IOException ex) {
        Logger.getLogger(PgNapesIO.class.getName()).log(Level.SEVERE, null, ex);
    }
}