Here you can find the source of parse(String str)
public static Date parse(String str) throws ParseException
//package com.java2s; /*//from w ww .j av a 2s. c om * Copyright 2017 StreamSets Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); private static final String ISO8601_UTC_MASK = "yyyy-MM-dd'T'HH:mm'Z'"; public static Date parse(String str) throws ParseException { return getISO8601DateFormat().parse(str); } private static DateFormat getISO8601DateFormat() { DateFormat dateFormat = new SimpleDateFormat(ISO8601_UTC_MASK); // Stricter parsing to prevent dates such as 2011-12-50T01:00Z (December 50th) from matching dateFormat.setLenient(false); dateFormat.setTimeZone(UTC); return dateFormat; } }