get LocalDateTime From Millisecond - Java java.time

Java examples for java.time:LocalDateTime

Description

get LocalDateTime From Millisecond

Demo Code

/*//from ww w  .  j  a  v  a  2 s .  c  o  m
 * Copyright 2014-2015 Christian Raue
 * MIT License http://opensource.org/licenses/mit-license.php
 */
//package com.java2s;

import java.time.LocalDateTime;

import java.time.temporal.ChronoUnit;

public class Main {
    /**
     * @param millis UTC-basierter Datum/Zeit-Wert in ms
     * @return Datum/Zeit-Wert
     */
    public static LocalDateTime getLocalDateTimeFromMillis(final long millis) {
        return LocalDateTime.of(1970, 1, 1, 0, 0, 0).plus(millis,
                ChronoUnit.MILLIS);
    }
}

Related Tutorials