LocalDateTime To Millisecond UTC - Java java.time

Java examples for java.time:LocalDateTime

Description

LocalDateTime To Millisecond UTC

Demo Code


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

import java.time.ZoneOffset;

public class Main {
    public static long dateTimeToMillisUTC(LocalDateTime dateTime) {
        return dateTime.toInstant(ZoneOffset.UTC).toEpochMilli();
        //return dateTime.toEpochSecond(ZoneOffset.UTC);
    }//from w  ww  .  j a v  a 2 s.  c  o m
}

Related Tutorials