get LocalDateTime From Timestamp - Java java.time

Java examples for java.time:LocalDateTime

Description

get LocalDateTime From Timestamp

Demo Code


//package com.java2s;
import java.time.Instant;

import java.time.LocalDateTime;

import java.util.TimeZone;

public class Main {
    public static LocalDateTime getDateTimeFromTimestamp(long timestamp) {
        if (timestamp == 0)
            return null;
        return LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp),
                TimeZone.getDefault().toZoneId());
    }//from  w ww . j  a v a 2  s  .  c  o m
}

Related Tutorials