Java LocalDate Calculate asEpochMilli(final LocalDate localDate)

Here you can find the source of asEpochMilli(final LocalDate localDate)

Description

Converts a LocaleDate into milliseconds from the epoch of 1970-01-01T00:00:00Z.

License

Open Source License

Parameter

Parameter Description
localDate LocalDate to convert

Return

and equivalent milliseconds from the epoch of 1970-01-01T00:00:00Z

Declaration

public static long asEpochMilli(final LocalDate localDate) 

Method Source Code

//package com.java2s;
/*/*from   w  ww.j a  va 2 s .co  m*/
 * jGnash, a personal finance application
 * Copyright (C) 2001-2019 Craig Cavanaugh
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.time.LocalDate;

import java.time.ZoneId;

public class Main {
    private static final int MILLISECONDS_PER_SECOND = 1000;

    /**
     * Converts a LocaleDate into milliseconds from the epoch of 1970-01-01T00:00:00Z.
     *
     * @param localDate {@code LocalDate} to convert
     * @return and equivalent milliseconds from the epoch of 1970-01-01T00:00:00Z
     */
    public static long asEpochMilli(final LocalDate localDate) {
        return localDate.atStartOfDay(ZoneId.systemDefault()).toEpochSecond() * MILLISECONDS_PER_SECOND;
    }
}

Related

  1. adjustDate(final LocalDate contextDate, String str, final boolean add)
  2. asDate(LocalDate date)
  3. atEndOfDay(LocalDate date)
  4. before(final LocalDate d1, final LocalDate d2)
  5. calcNextDayOfWeek(LocalDate d, DayOfWeek dow)
  6. calculateAge(LocalDate birthDate, LocalDate currentDate)