Here you can find the source of changeDateWithSplit(String argDate, String split)
public static String changeDateWithSplit(String argDate, String split)
//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; } }