List of utility methods to do Date String Format
String | formatDateLog(String dateStr) Formats the date string to the string that begins with " [ " and ends with "] ".
StringBuffer sb = new StringBuffer(""); sb.append("["); sb.append(dateStr); sb.append("]"); return sb.toString(); |
String | formatDateString(String dateString) Change date format from MM/dd/YYYY to yyyy/MM/dd String arrStr[] = dateString.split(DEFAULT_DELIMETER); if (arrStr[1].length() == 1) arrStr[1] = String.format("0%s", arrStr[1]); if (arrStr[0].length() == 1) arrStr[0] = String.format("0%s", arrStr[0]); return String.format("%s-%s-%s", arrStr[2], arrStr[0], arrStr[1]); |
String | FormatDateString(String dateString) Format Date String String[] dateSplit = null; String result; if (dateString.contains("-")) { dateSplit = dateString.split("-"); } else if (dateString.contains("/")) { dateSplit = dateString.split("/"); try { ... |
String | formatDateToParse(String date, String errorMessage) format Date To Parse if (!date.contains("Z")) { int lastColonIndex = date.lastIndexOf(":"); if (lastColonIndex < 0) { throw new IllegalArgumentException(errorMessage + date); date = date.substring(0, lastColonIndex) + date.substring(lastColonIndex + 1, date.length()); } else { date = date.replace("Z", "+0000"); ... |
String | formatDay(String date) format Day String result = null; String[] tmp = date.split("\\-"); String year = tmp[0]; String month = tmp[1]; String day = tmp[2]; if (Integer.parseInt(month) < 10) { month = "0" + month; if (Integer.parseInt(day) < 10) { day = "0" + day; result = year + "-" + month + "-" + day; return result; |
String | formate8Date(String str) formate Date if (str.length() == 8) { return str.substring(0, 4) + "-" + str.substring(4, 6) + "-" + str.substring(6, 8); return str; |
String | formatIso8601ToSimpleDate(String iso8601) format Iso To Simple Date String date = iso8601.split("T")[0]; String[] parts = date.split("-"); StringBuilder sb = new StringBuilder(); sb.append(parts[2]).append(DATE_SEPARATOR).append(parts[1]).append(DATE_SEPARATOR).append(parts[0]); return sb.toString(); |
String | formatISODate(String date) Method to format an inputed date to the iso format of either yyyy, yyyy-mm, or yyyy-mm-dd if (date.matches("\\d{1,4}")) { return padYear(date); } else if (date.matches("\\d{1,4}-\\d{1,2}")) { String[] sa = date.split("-"); return padYear(sa[0]) + "-" + padMonthOrDay(sa[1]); } else if (date.matches("\\d{1,4}-\\d{1,2}-\\d{1,2}")) { String[] sa = date.split("-"); return padYear(sa[0]) + "-" + padMonthOrDay(sa[1]) + "-" + padMonthOrDay(sa[2]); ... |
String | formatMinDateForShowWith_(String str) format Min Date For Show Wit_ String res = ""; try { if (str.length() >= 4) { res += str.substring(0, 4); if (str.length() >= 6) { res += "-" + Integer.parseInt(str.substring(4, 6)); if (str.length() >= 8) { res += "-" + Integer.parseInt(str.substring(6, 8)); } catch (Exception e) { e.printStackTrace(); } finally { return res; |
String | formatQuery(String queryDate) format Query String str[] = queryDate.split("-"); String year = str[0]; String month = str[1]; String day = str[2]; return year + month + day; |