List of utility methods to do Date to Time
String | getTimeString(java.util.Date date) get Time String if (date == null) return ""; SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); String NDate = formatter.format(date); return NDate; |
String | getTimeText(Date date) get Time Text Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int hour = calendar.get(Calendar.HOUR_OF_DAY); String hourText = String.valueOf(hour); if (hour < 10) { hourText = '0' + hourText; int minutes = calendar.get(Calendar.MINUTE); ... |
String | getXSDDateTime() get XSD Date Time SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); return simpleDateFormat.format(new Date()); |
String | getXsdDateTime(Date time) get Xsd Date Time Date now = time; DateFormat ISO8601Local = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); TimeZone timeZone = TimeZone.getDefault(); ISO8601Local.setTimeZone(timeZone); int offset = timeZone.getOffset(now.getTime()); String sign = "+"; if (offset < 0) { offset = -offset; ... |
String | getXsdDateTime(final Date d) get Xsd Date Time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); if (d != null) { return sdf.format(d); } else { return sdf.format(new Date()); |
Date | removeTime(Date date) remove Time try { return removeTimeDateFormat.parse(removeTimeDateFormat.format(date)); } catch (ParseException e) { e.printStackTrace(); throw new RuntimeException(e); |
String | serializeDateTime(final Date date) Serialise a date as xsd:dateTime format with seconds to three decimal places (non-canonical) final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return format.format(date); |
String | serializeXsdDateTime(Date date) serialize Xsd Date Time return serializeXsdDateTime(date, TimeZone.getDefault());
|
String | strTime(Date dt) str Time DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return df.format(dt);
|
String | to24HrTimeString(Date date) Return the formatted string of the given date instance based on the 24 hour format specified for time in the System property. if (date == null) return null; String timeformat = null; timeformat = time24HrFormat; return format(date, timeformat); |