Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

impossible to set minutes ?

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)


thanks,,,

iosman

1 Reply
vapukov
Master II
Master II

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