Java Date String Format FormatDate(String strDate, char DateSeparator)

Here you can find the source of FormatDate(String strDate, char DateSeparator)

Description

Format Date

License

Open Source License

Parameter

Parameter Description
strDate a parameter
DateSeparator a parameter

Declaration

public static String FormatDate(String strDate, char DateSeparator) 

Method Source Code

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

public class Main {

    public static String FormatDate(String strDate, char DateSeparator) {
        String strOutDate;//from   www.j a  v a2  s.c  om
        int Len;
        Len = strDate.length();
        if ((Len != 6) && (Len != 8))
            strOutDate = strDate;
        else {
            if (Len == 6) {
                strDate = strDate.substring(0, 2) + DateSeparator + strDate.substring(2, 4) + DateSeparator
                        + strDate.substring(4);
                strOutDate = strDate;
            } else {
                strDate = strDate.substring(0, 4) + DateSeparator + strDate.substring(4, 6) + DateSeparator
                        + strDate.substring(6);
                strOutDate = strDate;
                strOutDate = strDate;
            }
        }
        return strOutDate;
    }
}

Related

  1. formatDate(String date)
  2. formatDate(String date)
  3. formatDate(String date, int format)
  4. formatDate(String dateString, String delimiter)
  5. formatDate(String fieldName)
  6. formatDate(String unformattedDate, String format)
  7. formatDate(String values)
  8. FormatDate6(String strDate)
  9. formatDateLog(String dateStr)