Java Utililty Methods Date String to String

List of utility methods to do Date String to String

Description

The list of methods to do Date String to String are organized into topic(s).

Method

StringdateToDateEN(String in)
date To Date EN
return in.replaceAll("\u5E74", "-").replaceAll("\u6708", "-").replaceAll("\u65E5", "");
StringdateToFileName(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;
intdateToInt(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;
StringdateToString(String date)
date To String
String stringDate = "";
if (date.length() == 10 && date.indexOf("-") > 0) {
    stringDate = getYYYYMMDD(date);
} else {
    stringDate = date;
return stringDate;
StringdateToString(String date, String month)
date To String
if (date.length() == 1)
    date = "0" + date;
return monthAlphaToNum(month) + date;
StringadjustDate(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());