List of utility methods to do Date to String
String | dateToISODate(Date date) date To ISO Date TimeZone tz = TimeZone.getTimeZone("UTC"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); dateFormat.setTimeZone(tz); return dateFormat.format(date); |
String | dateToOracleDateString(Date date) date To Oracle Date String System.out.println("To Oracle Date; [" + formatDate(date, "dd-MMM-yy") + "]"); return formatDate(date, "dd-MMM-yy"); |
String | dateToRelativeTime(Date date) date To Relative Time SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date now = new Date(); long between = (now.getTime() - date.getTime()) / 1000; long day = between / (24 * 3600); long hour = between % (24 * 3600) / 3600; long minute = between % 3600 / 60; long second = between; String timeStr; ... |
String | dateToRFC1123(Date date) date To RFC SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, new Locale("en")); dateFormat.setTimeZone(TimeZone.getTimeZone(GMT)); String result = dateFormat.format(date); return result; |
String | dateToRFC3339(Date d) Format dates as specified in rfc3339 (required for Atom dates) StringBuilder result = new StringBuilder(rfc3339.format(d)); Calendar cal = new GregorianCalendar(); cal.setTime(d); cal.setTimeZone(TimeZone.getDefault()); int offset_millis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); int offset_hours = Math.abs(offset_millis / (1000 * 60 * 60)); int offset_minutes = Math.abs((offset_millis / (1000 * 60)) % 60); if (offset_millis == 0) { ... |
String | dateToStr(Date date) date To Str String s = ""; if (date == null) { return ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { s = sdf.format(date); } catch (Exception e) { ... |
String | dateToStr(Date date) date To Str if (date == null) { return ""; return dateToString(date, NORMAL_PATTERN); |
String | dateToStr(Date date) date To Str return dateToStr(date, "yyyy/MM/dd"); |
String | dateToStr(Date date) date To Str SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return formatter.format(date).trim(); |
String | dateToStr(Date date, int type) date To Str switch (type) { case 0: return dateToStr(date); case 1: return dateToStr(date, "yyyy/MM"); case 2: return dateToStr(date, "yyyyMMdd"); case 11: ... |