Java yyyy formatDateFromStringToString(String str)

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

Description

format Date From String To String

License

Apache License

Declaration

public static String formatDateFromStringToString(String str) 

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 formatDateFromStringToString(String str) {
        SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat sf2 = new SimpleDateFormat("yyyy-MM-dd");
        try {//from ww w. jav a2s  . c om
            return sf2.format(sf1.parse(str));
        } catch (ParseException e) {
            return "";
        }
    }
}

Related

  1. formatDate2DateStr()
  2. formatDate2DateStr()
  3. formatDate2ShortStr(Date date)
  4. formatDate2Str(Date date)
  5. formatDateAsShortDateLocalTime(Date moonDate, TimeZone tz)
  6. formatDateNoTime(Date date)
  7. formatDateString(java.util.Date date, String format)
  8. formatDateToString(Date d)
  9. formatDateToString(String strDate)