All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.logz.sawmill.DateTemplateHandler Maven / Gradle / Ivy

The newest version!
package io.logz.sawmill;

import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.function.Function;

public class DateTemplateHandler {

    // keep compatibility until we change configs
    public Function date() {
        return this::getCurrentDateByFormat;
    }

    public Function dateTemplate() {
        return this::getCurrentDateByFormat;
    }

    private String getCurrentDateByFormat(String dateFormat) {
        return DateTimeFormatter.ofPattern(dateFormat).format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()), ZoneOffset.UTC));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy