Java Parse Date Pattern YYYY parseStringDateToRmFormat(String date)

Here you can find the source of parseStringDateToRmFormat(String date)

Description

Convert String from dd.MM.yyyy to yyyy-MM-dd.

License

Open Source License

Parameter

Parameter Description
timestamp a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static String parseStringDateToRmFormat(String date) 

Method Source Code

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/*w w  w  .  ja v  a2  s  . com*/
     * Convert String from dd.MM.yyyy to yyyy-MM-dd.
     * 
     * @param timestamp
     * @return
     * @throws Exception
     */
    public static String parseStringDateToRmFormat(String date) {
        SimpleDateFormat sdfOld = new SimpleDateFormat("dd.MM.yyyy");
        SimpleDateFormat sdfNew = new SimpleDateFormat("yyyy-MM-dd");
        Date d;
        try {
            d = sdfOld.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
        return sdfNew.format(d);
    }
}

Related

  1. parseString2Date(String date)
  2. parseString2Date(String sDate, String format)
  3. parseString2Long(String strDate)
  4. parseStringAsDate(String pattern, String value)
  5. parseStringDate(String dateAsString)
  6. parseStringForDate(String dateString)
  7. parseStringToCalendar(String strDate)
  8. parseStringToDate(final String pDate, final String... pFormat)
  9. parseStringToDate(String date)