impossible to set minutes ?

Highlighted
Four Stars

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

Forteen Stars

Re: impossible to set minutes ?

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
-----------

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

The Forrester Wave: Strategic iPaaS and Hybrid Integration Platforms, Q1 2019

Find out how Forrester rate different iPaaS and Hybrid Integration Platforms

Read

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog