Java Date Format Change convertDate(String str)

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

Description

convert Date

License

Apache License

Declaration

public static String convertDate(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 convertDate(String str) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        return sdf1.format(sdf.parse(str));
    }//from w w  w  .  j a  va  2s .co m
}

Related

  1. convertDate(String date, String sourceFormat, String destinationFormat)
  2. convertDate(String date, String[] formats)
  3. convertDate(String dateIn, String fromDateFormat, String toDateFormat)
  4. convertDate(String inPattern, String outPattern, String date)
  5. convertDate(String inPattern, String outPattern, String date)
  6. convertDate(String value)
  7. convertDateFormat(String date, SimpleDateFormat formatBefore, SimpleDateFormat formatAfter)
  8. convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)
  9. convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)