Java Instant Format formatTimeLocal(Instant instant)

Here you can find the source of formatTimeLocal(Instant instant)

Description

Returns the instant formatted as only time using the local timezone.

License

Open Source License

Parameter

Parameter Description
instant the instant to format

Return

the instant's time in the local timezone

Declaration

public static String formatTimeLocal(Instant instant) 

Method Source Code


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

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

public class Main {
    /**/*from w  w  w.  j a  v  a2  s .  com*/
     * Returns the instant formatted as only time using the local timezone.
     *
     * @param instant the instant to format
     * @return the instant's time in the local timezone
     */
    public static String formatTimeLocal(Instant instant) {
        DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)
                .withZone(ZoneId.systemDefault());
        return formatter.format(instant);
    }
}

Related

  1. formatDate(Instant date, Locale locale)
  2. formatDateForInstant(Instant instant)
  3. formatHttpDate(Instant instant)
  4. formatInstant(TemporalAccessor instant)
  5. formatIso8601Date(Instant date)
  6. parseInstant(String dateString, DateTimeFormatter formatter)
  7. toInfluxDBTimeFormat(final Instant time)