Java LocalDateTime from dateToLong(LocalDateTime date)

Here you can find the source of dateToLong(LocalDateTime date)

Description

Convert a UTC LocalDateTime to a long milliseconds value for storage in the database

License

Open Source License

Parameter

Parameter Description
date The date

Return

The long value

Declaration

public static long dateToLong(LocalDateTime date) 

Method Source Code

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

import java.time.LocalDateTime;
import java.time.ZoneOffset;

public class Main {
    /**/*from   w w w  . j a  v a 2 s  . com*/
     * Convert a UTC {@link LocalDateTime} to a {@code long}
     * milliseconds value for storage in the database
     * @param date The date
     * @return The long value
     */
    public static long dateToLong(LocalDateTime date) {
        return date.toInstant(ZoneOffset.UTC).toEpochMilli();
    }
}

Related

  1. convertToLocalDateTime(String time)
  2. convertToSystemTime(LocalDateTime userInput, ZoneId userZoneId)
  3. dateToLocalDateTime(Date date)
  4. localDateTimeFromDate(Date date)