List of utility methods to do Date String to String
String | dateToDateEN(String in) date To Date EN return in.replaceAll("\u5E74", "-").replaceAll("\u6708", "-").replaceAll("\u65E5", ""); |
String | dateToFileName(String date) date To File Name String separator = "_"; date = date.replaceAll(" ", separator); date = date.replaceAll("\\.", separator); date = date.replaceAll(":", separator); date = date.replaceAll("-", separator); date = date.replaceAll("/", separator); return date; |
int | dateToInt(String date) date To Int int intDate = 0; if (date.length() == 8 && date.indexOf("-") < 0) { intDate = Integer.valueOf(date).intValue(); } else if (date.length() == 10 && date.indexOf("-") > 0) { intDate = Integer.valueOf(getYYYYMMDD(date)).intValue(); } else if (date.length() == 6 || date.length() == 4) { intDate = Integer.valueOf(date).intValue(); return intDate; |
String | dateToString(String date) date To String String stringDate = ""; if (date.length() == 10 && date.indexOf("-") > 0) { stringDate = getYYYYMMDD(date); } else { stringDate = date; return stringDate; |
String | dateToString(String date, String month) date To String if (date.length() == 1) date = "0" + date; return monthAlphaToNum(month) + date; |
String | adjustDate(String format, String value) adjust Date SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = sdf.parse(value); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); if (cal.get(Calendar.YEAR) < 100) cal.add(Calendar.YEAR, 2000); return sdf.format(cal.getTime()); |