Search code examples
simulationanylogic

How can I set the 'start date' of model using a variable?


How can I set the 'start date' using a variable, including both the date and time that came with it?

enter image description here

What I have tried:

getExperiment().getEngine().setStartDate(dateTypeVariable);

When I tried to initialize my variable "dateTypeVariable" with my other variables "date" and "time", which are of type int, I received an error message indicating that I cannot use an int value in the date variable.

I think the main issue is how to initialize the variable "dateTypeVariable" with a specific date and time of my choice.


Solution

  • Simply construct the dateTypeVariable variable correctly using the Date constructor, for example Date(int year, int month, int date, int hrs, int min).

    However, many of these are deprecated and you may want to define it differently, see JavaDoc here.