Java OffsetDateTime stringifyDate(long timestamp)

Here you can find the source of stringifyDate(long timestamp)

Description

stringify Date

License

Apache License

Declaration

public static String stringifyDate(long timestamp) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.time.Instant;
import java.time.OffsetDateTime;

import java.time.ZoneOffset;

import java.util.TimeZone;

public class Main {
    public static String stringifyDate(OffsetDateTime date) {
        date = date.withOffsetSameInstant(ZoneOffset.ofHours(2));
        return (date.getDayOfMonth() < 10 ? "0" + date.getDayOfMonth() : date.getDayOfMonth()) + "/"
                + (date.getMonthValue() < 10 ? "0" + date.getMonthValue() : date.getMonthValue()) + "/"
                + date.getYear() + " " + (date.getHour() < 10 ? "0" + date.getHour() : date.getHour()) + ":"
                + (date.getMinute() < 10 ? "0" + date.getMinute() : date.getMinute());
    }/*from w  ww  . j  a  va  2 s  . co  m*/

    public static String stringifyDate(long timestamp) {
        return stringifyDate(
                OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), TimeZone.getTimeZone("GMT").toZoneId()));
    }
}

Related

  1. getNowOdt()
  2. hasZone(TemporalAccessor date)
  3. next(OffsetDateTime date, OffsetTime time)
  4. nowAtZone(String offsetId)
  5. parseDate(String raw)
  6. timeF(OffsetDateTime time, ZoneId zone)
  7. toCalendar(OffsetDateTime offsetDateTime)
  8. toRfc1123String(FileTime time)