Java Date Format Change changeDateFormatPattern(final DateFormat dateFormat, String regex, String replacement)

Here you can find the source of changeDateFormatPattern(final DateFormat dateFormat, String regex, String replacement)

Description

change Date Format Pattern

License

Open Source License

Declaration

private static DateFormat changeDateFormatPattern(final DateFormat dateFormat, String regex,
            String replacement) 

Method Source Code


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

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Main {
    private static DateFormat changeDateFormatPattern(final DateFormat dateFormat, String regex,
            String replacement) {
        if (dateFormat instanceof SimpleDateFormat) {
            SimpleDateFormat simpleDateFormat = (SimpleDateFormat) dateFormat;

            String pattern = simpleDateFormat.toPattern().replaceAll(regex, replacement);
            simpleDateFormat.applyPattern(pattern);

            return simpleDateFormat;
        }//  www.j  a v  a2s  .co m
        return dateFormat;
    }
}

Related

  1. changeDateFormat(String dateString, String srcFormat, String destFormat)
  2. changeDateTimeZone(String date_GMT)
  3. changeDateValue(Date firstDate, Date secondDate)
  4. convertDate(String date, String sourceFormat, String destinationFormat)
  5. convertDate(String date, String[] formats)