Here you can find the source of parse(String _date, String _format)
public static final Instant parse(String _date, String _format)
//package com.java2s; //License from project: Open Source License import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; public class Main { public static final ZoneOffset localZoneOffset = ZoneOffset.UTC; /**/*from www .ja v a 2s.c o m*/ * Get an Instant from string at local zone * * @return the corresponding Instant */ public static final Instant parse(String _date, String _format) { DateTimeFormatter format = DateTimeFormatter.ofPattern(_format); try { return LocalDateTime.parse(_date, format).toInstant(localZoneOffset); } catch (DateTimeParseException e) { try { return LocalDate.parse(_date, format).atStartOfDay().toInstant(localZoneOffset); } catch (DateTimeParseException e2) { throw e2; } } } }