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:Main.java

public static void main(String[] args) {
    Locale englishUS = Locale.US;
    LocalDateTime ldt = LocalDateTime.of(2014, Month.JANUARY, 25, 11, 48, 16);

    System.out.printf(englishUS, "US: %tB %<te,  %<tY  %<tT %<Tp%n", ldt);
}

From source file:Main.java

public static void main(String[] args) {

    LocalDateTime l = LocalDateTime.of(2012, Month.AUGUST, 13, 0, 0, 0);
    ZonedDateTime z = ZonedDateTime.of(LocalDateTime.of(2014, Month.AUGUST, 13, 0, 0, 0),
            ZoneId.of("America/Los_Angeles"));

    Duration duration = Duration.between(l, z);

    System.out.println(duration);
}

From source file:Main.java

public static void main(String[] args) {
    // current //from w ww. j a  va2 s .co m
    LocalDateTime localDateTime1 = LocalDateTime.now();
    System.out.println(localDateTime1);

    // 2014-06-21T16:12:34
    LocalDateTime localDateTime2 = LocalDateTime.of(2014, Month.JUNE, 21, 16, 12, 34);
    System.out.println(localDateTime2);
    // from  a  local date and  a  local  time
    LocalDate localDate1 = LocalDate.of(2014, 5, 10);
    LocalTime localTime = LocalTime.of(16, 18, 41);
    LocalDateTime localDateTime3 = LocalDateTime.of(localDate1, localTime);
    System.out.println(localDateTime3);
}

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

@RequestMapping("/{year:[0-9]{4}}")
public String year(@PathVariable int year, @PageableDefault(10) Pageable pageable, BlogLanguage blogLanguage,
        HttpServletRequest servletRequest, Model model) {
    ArticleSearchForm form = new ArticleSearchForm() {
    };/*  w ww .  j ava  2s  . c  o  m*/
    form.setLanguage(blogLanguage.getLanguage());
    form.setDateFrom(LocalDateTime.of(year, 1, 1, 0, 0, 0));
    form.setDateTo(LocalDateTime.of(year, 12, 31, 0, 0, 0));

    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:at.ac.tuwien.qse.sepm.service.impl.ClusterServiceTest.java

private Journey getViennaJourney() {
    return new Journey(4, "Vienna", LocalDateTime.of(2010, 8, 10, 0, 0, 0),
            LocalDateTime.of(2010, 8, 15, 0, 0, 0));
}

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

@Test
@WithData//ww w . ja  v a2  s .c om
public void createWithValidParameterShouldPersist() throws ValidationException, DAOException {
    int nrOfRows = countRows();
    journeyDAO.create(new Journey(null, "Vienna", LocalDateTime.of(2010, 3, 6, 0, 0, 0),
            LocalDateTime.of(2015, 3, 6, 0, 0, 0)));
    assertThat(countRows(), is(nrOfRows + 1));
}

From source file:fi.vrk.xroad.catalog.persistence.TestUtil.java

/**
 * @param day Day of month/*w ww.j a v  a 2  s  . c om*/
 * @param month 1 = January
 * @param year Year
 * @return LocalDateTime with zero hours
 */
public LocalDateTime createDate(int day, int month, int year) {
    return LocalDateTime.of(year, month, day, 0, 0, 0);
}

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

private Journey getDenverJourney() {
    return new Journey(3, "Denver", LocalDateTime.of(2005, 9, 10, 0, 0, 0),
            LocalDateTime.of(2005, 9, 12, 0, 0, 0));
}

From source file:net.consulion.jeotag.PhotoLoader.java

private static Instant getTimeTaken(final TiffImageMetadata exif, final File file) {
    Instant instant = null;//w  w w .  j  a  v a2 s .c o  m
    if (exif != null) {
        try {
            final String[] dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
            if (dateTimeOriginal.length == 1
                    && dateTimeOriginal[0].matches("\\d{4}\\:\\d{2}:\\d{2}\\s\\d{2}:\\d{2}:\\d{2}")) {
                final String[] split = dateTimeOriginal[0].split("\\s");
                final String dateString = split[0];
                final String timeString = split[1];
                final String[] dateSplit = dateString.split("\\:");
                final int year = Integer.parseInt(dateSplit[0]);
                final int month = Integer.parseInt(dateSplit[1]);
                final int day = Integer.parseInt(dateSplit[2]);
                final String[] timeSplit = timeString.split("\\:");
                final int hour = Integer.parseInt(timeSplit[0]);
                final int minute = Integer.parseInt(timeSplit[1]);
                final int second = Integer.parseInt(timeSplit[2]);
                final LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, minute, second);
                instant = ldt.toInstant(ZoneOffset.ofHoursMinutes(0, 0));
            } else {
                log(Level.WARNING, String.format("unknown date format in file %s", file.getPath()));
            }
        } catch (ImageReadException ex) {
            Logger.getLogger(PhotoLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return instant;
}

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

@RequestMapping("/{year:[0-9]{4}}/{month:[0-9]{2}}")
public String month(@PathVariable int year, @PathVariable int month, @PageableDefault(10) Pageable pageable,
        BlogLanguage blogLanguage, HttpServletRequest servletRequest, Model model) {
    ArticleSearchForm form = new ArticleSearchForm() {
    };/*  www  . j  a  v a 2 s .  c  o m*/
    form.setLanguage(blogLanguage.getLanguage());
    LocalDateTime date = LocalDateTime.of(year, month, 1, 0, 0, 0);
    form.setDateFrom(LocalDateTime.of(year, month, 1, 0, 0, 0));
    form.setDateTo(LocalDateTime.of(year, month, date.getMonth().length(true), 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";
}