Android Date String Parse changeDateWithSplit(String argDate, String split)

Here you can find the source of changeDateWithSplit(String argDate, String split)

Description

change Date With Split

Declaration

public static String changeDateWithSplit(String argDate, String split) 

Method Source Code

//package com.java2s;

public class Main {
    public static String changeDateWithSplit(String argDate, String split) {
        if (argDate == null || argDate.trim().equals("")) {
            return "";
        }//from  ww w.jav  a 2  s .co m
        if (split == null || split.trim().equals("")) {
            split = "-";
        }
        String result = "";
        if (argDate.length() == 10 && argDate.indexOf("/") > 0) {
            return argDate;
        }
        if (argDate.length() == 10 && argDate.indexOf("-") > 0) {
            return argDate;
        }
        String[] str = argDate.split("[.]");
        int LEN = str.length;
        for (int i = 0; i < LEN; i++) {
            if (str[i].length() == 1) {
                if (str[i].equals("0")) {
                    str[i] = "01";
                } else {
                    str[i] = "0" + str[i];
                }
            }
        }
        if (LEN == 1) {
            result = argDate + split + "01" + split + "01";
        }
        if (LEN == 2) {
            result = str[0] + split + str[1] + split + "01";
        }
        if (LEN == 3) {
            result = str[0] + split + str[1] + split + str[2];
        }
        return result;
    }
}

Related

  1. stringConvertDate(String date)
  2. stringToDate(String date)
  3. toDate(String string)
  4. tokenizeDate(String date)
  5. String2Date(String dateStr)
  6. isValidDate(String sDate)
  7. getDateTimeFromString(String dateTimeString, String format)
  8. convertStringToDate(String date, String time)
  9. GetDate(String time)