Java Parse Date parseDate(String date, Locale locale)

Here you can find the source of parseDate(String date, Locale locale)

Description

parse Date

License

Open Source License

Declaration

public static String parseDate(String date, Locale locale) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 Sebastian Hagedorn <sh@sernet.de>.
 * 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. /*  ww  w. ja v a  2 s .  c om*/
 * If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Sebastian Hagedorn <sh@sernet.de> - initial API and implementation
 ******************************************************************************/

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import java.util.Locale;

public class Main {
    public static String parseDate(String date, Locale locale) {

        SimpleDateFormat formatter = new SimpleDateFormat("EE, dd.MM.yyyy",
                locale);
        SimpleDateFormat destinationFormat = new SimpleDateFormat(
                "dd.MM.yyyy", locale);
        formatter.setLenient(true);
        try {
            Date fDate = formatter.parse(date);
            String ret = destinationFormat.format(fDate);
            return ret;
        } catch (ParseException e) {
            e.printStackTrace();
            return date;
        }
    }
}

Related

  1. parseDate(String date)
  2. parseDate(String date)
  3. parseDate(String date)
  4. parseDate(String date)
  5. parseDate(String date)
  6. parseDate(String date, String expression)
  7. parseDate(String date, String format)
  8. parseDate(String date, String format)
  9. parseDate(String date, String format)