Android Date Set changeDate(String argDate)

Here you can find the source of changeDate(String argDate)

Description

change Date

License

Apache License

Declaration

public static String changeDate(String argDate) 

Method Source Code

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

public class Main {

    public static String changeDate(String argDate) {
        if (argDate == null || argDate.trim().equals("")) {
            return "";
        }/*from   w ww  .  j a  va2  s  . c om*/
        String result = "";
        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 + "/01/01";
        }
        if (LEN == 2) {
            result = str[0] + "/" + str[1] + "/01";
        }
        if (LEN == 3) {
            result = str[0] + "/" + str[1] + "/" + str[2];
        }
        return result;
    }
}

Related

  1. setYears(Date date, int amount)
  2. shortDate(Date date)
  3. time(Date date)
  4. toDateTime(Date date, Date time)
  5. offsetDate(Date date, int field, int offset)
  6. firstTimeOfDate(Date date)
  7. resetTime(Date date)
  8. removeTime(Date date)