Java DateTimeFormatter format(DateTimeFormatter formatter, Object object)

Here you can find the source of format(DateTimeFormatter formatter, Object object)

Description

Formats a TemporalAccessor object into a String using the specified DateTimeFormatter .

License

Open Source License

Parameter

Parameter Description
formatter DateTimeFormatter to be used to format the date object
object Instant to format

Return

String representation of the

Declaration

public static String format(DateTimeFormatter formatter, Object object) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.time.format.DateTimeFormatter;

import java.time.temporal.TemporalAccessor;

public class Main {
    /**//from   www.j  a v a 2 s.c  om
     * <p>
     * Formats a {@link TemporalAccessor} object into a {@code String} using the
     * specified {@link DateTimeFormatter}.
     * </p>
     *
     * <p>
     * This method was implemented for allowing
     * {@link org.dei.perla.core.message.Mapper}s to format an unknown object
     * of PerLa type TIMESTAMP.
     * </p>
     *
     * @param formatter
     *            {@link DateTimeFormatter} to be used to format the date object
     * @param object
     *            {@link Instant} to format
     * @return String representation of the {@link Instant}
     */
    public static String format(DateTimeFormatter formatter, Object object) {
        return format(formatter, (TemporalAccessor) object);
    }

    /**
     * Formats a {@link TemporalAccessor} object into a {@code String} using the
     * specified {@link DateTimeFormatter}.
     *
     * @param formatter
     *            {@link DateTimeFormatter} to be used to format the date object
     * @param instant
     *            {@link Instant} to format
     * @return String representation of the {@link Instant}
     */
    public static String format(DateTimeFormatter formatter, TemporalAccessor instant) {
        return formatter.format(instant);
    }
}

Related

  1. convertToEpochMillis(String logTimestamp, DateTimeFormatter logTimeFormat)
  2. create14DigitDateTimeFormat()
  3. createFormatterFromPatternString(String formatPattern, Locale locale)
  4. dateTimeFormatterNCForPattern(String pattern)
  5. format(long epochMilliSecond)
  6. formatAgo(long timestamp)
  7. formatByLocale(Date date, Locale locale)
  8. formatDate(long date)