Java ZonedDateTime Calculate getTimePath(Path dir, String ext, ZonedDateTime dateTime)

Here you can find the source of getTimePath(Path dir, String ext, ZonedDateTime dateTime)

Description

get Time Path

License

Open Source License

Declaration

public static final Path getTimePath(Path dir, String ext, ZonedDateTime dateTime) 

Method Source Code


//package com.java2s;
/*//from w  ww .j  av a 2  s.c  om
 * Copyright (C) 2018 Timo Vesalainen <timo.vesalainen@iki.fi>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.nio.file.Path;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;

public class Main {
    public static final Path getTimePath(Path dir, String ext) {
        return getTimePath(dir, ext, ZonedDateTime.now(ZoneOffset.UTC));
    }

    public static final Path getTimePath(Path dir, String ext, ZonedDateTime dateTime) {
        if (!ext.startsWith(".")) {
            ext = "." + ext;
        }
        String pattern = "yyyyMMddHHmmss'" + ext + "'";
        DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
        builder.appendPattern(pattern);
        DateTimeFormatter formatter = builder.toFormatter();
        return dir.resolve(dateTime.format(formatter));
    }
}

Related

  1. getDuration(ZonedDateTime input, TemporalField roundTo, int roundIncrement)
  2. getShortStringDate(ZonedDateTime time)
  3. getStartOfDay(ZoneId zoneId, ZonedDateTime time)
  4. getStartOfWeek(ZoneId zoneId, ZonedDateTime time)
  5. getTime(ZonedDateTime zonedTime)
  6. getZonedDateTimeForComparison(TimeZone zone)
  7. holidaysInRange(ZonedDateTime startDate, ZonedDateTime endDate, List holidays)
  8. isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime, ZonedDateTime endDateTime)
  9. isoDateTime(ZonedDateTime zonedDateTime)