Here you can find the source of toBadDate(LocalDate localDate, ZoneId timezone)
Parameter | Description |
---|---|
localDate | A date without time. |
timezone | A time zone. We'll calculate milliseconds from the epoch from this particular time zone. |
public static Date toBadDate(LocalDate localDate, ZoneId timezone)
//package com.java2s; /*//www .j a va 2 s.c om * Copyright (c) 2012. The Genome Analysis Centre, Norwich, UK * MISO project contacts: Robert Davey @ TGAC * ********************************************************************* * * This file is part of MISO. * * MISO 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. * * MISO 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 MISO. If not, see <http://www.gnu.org/licenses/>. * * ********************************************************************* */ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; public class Main { /** * Switches from a representation of date without time or a time zone to one that contains milliseconds from epoch as interpreted from * some place with a time zone. No good will come of this. Turn back now. * * @param localDate A date without time. * @param timezone A time zone. We'll calculate milliseconds from the epoch from this particular time zone. * @return Milliseconds from the epoch. */ public static Date toBadDate(LocalDate localDate, ZoneId timezone) { return localDate == null ? null : Date.from(localDate.atStartOfDay( timezone).toInstant()); } public static Date toBadDate(LocalDate localDate) { return toBadDate(localDate, ZoneId.systemDefault()); } public static Date toBadDate(LocalDateTime localDate) { return localDate == null ? null : toBadDate(localDate.toLocalDate()); } }