Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I try to use the TalendDate.setDate function. It works fine with the following statement:
tmpDate = TalendDate.setDate(context.CurEndDate, 0, "HH");
It sets the hour to 00
but when I want to set the minutes to 00:
tmpDate = TalendDate.setDate(context.CurEndDate, 0, "mm");
it says :
java.lang.RuntimeException: Can't support the dateType: mm
Why can't we set minutes using this function ?
And how can I work this around to set my date to midnight (for instance: 2012-04-03 12:00 becomes 2012-04-03 00:00)
iosman
Hi,
what version of Talend do you use?
function code contain minutes as part of parameters:
if (dateType.equalsIgnoreCase("yyyy")) { //$NON-NLS-1$ c.set(Calendar.YEAR, nb); } else if (dateType.equals("MM")) { //$NON-NLS-1$ c.set(Calendar.MONTH, nb - 1); } else if (dateType.equalsIgnoreCase("dd")) { //$NON-NLS-1$ c.set(Calendar.DATE, nb); } else if (dateType.equalsIgnoreCase("HH")) { //$NON-NLS-1$ c.set(Calendar.HOUR_OF_DAY, nb); } else if (dateType.equals("mm")) { //$NON-NLS-1$ c.set(Calendar.MINUTE, nb); } else { throw new RuntimeException("Can't support the dateType: " + dateType); } return c.getTime();
and it works:
System.out.println(TalendDate.setDate(new Date(),0,"mm")); [statistics] connected Tue Jul 23 18:00:06 NZST 2019 [statistics] disconnected