List of utility methods to do Date to Time
Date | getTimeByOffset(Date reqDate, int offset) get Time By Offset Date result;
Calendar cal = Calendar.getInstance();
cal.setTime(reqDate);
cal.add(Calendar.HOUR, offset);
result = cal.getTime();
return result;
|
java.util.Date | getTimeDateByMinuteAndSeconds(Integer minutes, Integer seconds) getTimeDateByMinuteAndSeconds: converts the minutes to an Date object {Category} TimestampUtil {talendTypes} Date {param} Integer(5): minutes {param} Integer(5): seconds {example} getTimeDateByMinuteAndSeconds(90,120). if (minutes != null || seconds != null) { java.util.Calendar c = java.util.Calendar.getInstance(getUTCTimeZone()); c.setTime(new java.util.Date(0l)); c.set(java.util.Calendar.HOUR_OF_DAY, 0); c.set(java.util.Calendar.MINUTE, 0); c.set(java.util.Calendar.SECOND, 0); if (minutes != null) { c.add(java.util.Calendar.MINUTE, minutes); ... |
String | getTimeDateStr(Date date) get Time Date Str if (date == null) { return null; Calendar cal = Calendar.getInstance(); cal.setTime(date); return getFixedTwoStr(cal.get(Calendar.HOUR_OF_DAY)) + ":" + getFixedTwoStr(cal.get(Calendar.MINUTE)) + " " + cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR); ... |
int | getTimeDeltaValue(Date t, Date baseDate, String tDelta) Get time value - Time delta value of base date Calendar cal = Calendar.getInstance(); cal.setTime(baseDate); long sl = cal.getTimeInMillis(); long el, delta; int value = 0; cal.setTime(t); el = cal.getTimeInMillis(); delta = el - sl; ... |
long | getTimeFromDate(Date date) get Time From Date Date now = Calendar.getInstance().getTime(); long timePortion = now.getTime() % MILLIS_PER_DAY; return timePortion; |
int | getTimeFromDate(final Date date) Create an integer time from a Date object.
final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); final int hour = calendar.get(Calendar.HOUR_OF_DAY) * 100; final int minute = calendar.get(Calendar.MINUTE); return hour + minute; |
long | getTimeImMillis(Date date) get Time Im Millis Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.getTimeInMillis();
|
int | getTimeInSeconds(Date date) Gets time in seconds. Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.HOUR_OF_DAY) * 60 * 60 + calendar.get(Calendar.MINUTE) * 60
+ calendar.get(Calendar.SECOND);
|
String | getTimeInterval(Date fromDate) get Time Interval Calendar cal = Calendar.getInstance();
Date currentDate = cal.getTime();
return getTimeInterval(fromDate, currentDate);
|
int | getTimeIntervalMins(Date firstDate, Date lastDate) get Time Interval Mins if (null == firstDate || null == lastDate) { return -1; long intervalMilli = lastDate.getTime() - firstDate.getTime(); return (int) (intervalMilli / (60 * 1000)); |