Java Date from String convertToDate(String str)

Here you can find the source of convertToDate(String str)

Description

convert To Date

License

Apache License

Declaration

public static String convertToDate(String str) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;

import java.text.SimpleDateFormat;

public class Main {
    public static String convertToDate(String str) throws ParseException {
        if (str == null)
            return null;
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(sdf1.parse(str));
    }/*from w  w w. j a  va2  s  . c o m*/
}

Related

  1. convertToDate(String dateString, String format)
  2. convertToDate(String dateString, String pattern)
  3. convertToDate(String ddMMyy)
  4. convertToDate(String inDate)
  5. convertToDate(String input)
  6. convertToDate(String str, String format)
  7. convertToDate(String strDate, String format)
  8. convertToDate(String strDate, String format)
  9. convertToDate(String val)