I have checked and apparently you can't left-pad zero onto an integer. Converting to string and back to integer doesn't work either. Although, what I am trying to do is use the integer for a FOR loop and then send into a JPQL query, using concatenation, which needs the date format to be in XML Gregorian Calendar(YYYY-MM-DD HH:MM:SS).
One way to solve my problem would be to use formatter before sending it into a JPQL query. What I mean to ask is : Is there a better way to do this, in my case?
Here is the relevant piece of code:
for (int month = startMonth; month <= endMonth; month++) {
inputDates = "SELECT COUNT(d) FROM Datafile d WHERE d.datafileCreateTime BETWEEN {ts 2013-" +month+ "-01 00:00:00} AND {ts 2013-" +month+ "-02 23:59:59}";
...