Java Date Format Change convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)

Here you can find the source of convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)

Description

convert Date Format

License

Open Source License

Declaration

public static String convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)
        throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static String convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)
            throws ParseException {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new SimpleDateFormat(sourceDateFormat).parse(sourceDate));
        String destDate = new SimpleDateFormat(destDateFormat).format(calendar.getTime());
        return destDate;
    }/*from  ww w .j a v  a 2 s  . c om*/
}

Related

  1. convertDate(String inPattern, String outPattern, String date)
  2. convertDate(String inPattern, String outPattern, String date)
  3. convertDate(String str)
  4. convertDate(String value)
  5. convertDateFormat(String date, SimpleDateFormat formatBefore, SimpleDateFormat formatAfter)
  6. convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)
  7. convertDateFromInDayFormat(String stringDate, String hhmmss)
  8. convertDateFromTo(String stringDate, String patternToUse, TimeZone timezoneIn, TimeZone timezoneOut)
  9. convertDateStringToString(String dateString, String format)