Date creation

0
Hi All, why I can use this? dateTimeUTC($MyYear) where MyYear variable is Integer/Float ... Mendix is saying that first argument must be literal Integer. How can I solve this simple operation? Regards, Lukas
asked
3 answers
0

I have found the workaround ...

Use this intead of the previous ...

parseDateTimeUTC($ActualYear + '-' + $StartMonth + '-' + 1, 'yyyy-MM-dd').

But I have to say this doesn't make sense.

Lukas

answered
0

Did you checked this: parseDateTime is trying to parse a datetime from a string value. You can specify the format in the second parameter.

Are you converting a string to a datetime, or are you trying to create a datetime with only 1 parameter? You can create a date with the dateTimeUTC function, see this link.

answered
0

Another option is a JavaAction. 3 Parameters: Year, Month, Day (Integer/Long).

{
    // BEGIN USER CODE
    Calendar cal = Calendar.getInstance();

    //Clear all fields
    cal.clear();

    cal.set(Calendar.YEAR, Year.intValue());
    // month is zerobased
    cal.set(Calendar.MONTH, Month.intValue()-1);
    cal.set(Calendar.DATE, Day.intValue());

    //Create instance of java.util.Date
    java.util.Date utilDate = cal.getTime();

    return cal.getTime();
    // END USER CODE
}

Needs

import java.util.Calendar;
import java.util.Date;
answered