Here you can find the source of parseDateList(List
public static List<Date> parseDateList(List<String> dateList)
//package com.java2s; /******************************************************************************* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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./*from www.j a va 2 s. co m*/ *******************************************************************************/ import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Main { /** Returns a List of parsed date strings. */ public static List<Date> parseDateList(List<String> dateList) { List<Date> newList = new ArrayList<Date>(); if (dateList == null) return newList; for (String value : dateList) newList.add(parseDate(value)); return newList; } /** Returns a Date object from a String. */ public static Date parseDate(String dateStr) { String formatString = ""; if (dateStr.length() == 16) dateStr = dateStr.substring(0, 14); if (dateStr.length() == 15) formatString = "yyyyMMdd'T'hhmmss"; if (dateStr.length() == 8) formatString = "yyyyMMdd"; SimpleDateFormat formatter = new SimpleDateFormat(formatString); ParsePosition pos = new ParsePosition(0); return formatter.parse(dateStr, pos); } }