Java Date Format Change convertDateStringToString(String strDate, String currentFormat, String parseFormat)

Here you can find the source of convertDateStringToString(String strDate, String currentFormat, String parseFormat)

Description

convert Date String To String

License

Apache License

Declaration

public static String convertDateStringToString(String strDate, String currentFormat, String parseFormat) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String convertDateStringToString(String strDate, String currentFormat, String parseFormat) {
        try {// w  w  w . j  a v  a  2s .  c o m
            return convertDateToString(convertStringToDate(strDate, currentFormat), parseFormat);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String convertDateToString(Date objDate, String parseFormat) {
        try {
            return new SimpleDateFormat(parseFormat).format(objDate);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static Date convertStringToDate(String strDate, String parseFormat) {
        try {
            return new SimpleDateFormat(parseFormat).parse(strDate);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)
  2. convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)
  3. convertDateFromInDayFormat(String stringDate, String hhmmss)
  4. convertDateFromTo(String stringDate, String patternToUse, TimeZone timezoneIn, TimeZone timezoneOut)
  5. convertDateStringToString(String dateString, String format)
  6. convertDatetimeFormat(Date tar_date, String date_format)
  7. convertIso8601FormatToArsTime(String timeString)
  8. convertIso8601FormatToArsTimeOfDay(String timeOfDayString)
  9. convertISO8610ToCalendar(String iso8601string)