I'm trying to populate a TextField in JasperReport with the duration of some kind. This field's value is in miliseconds and to make it readable to user, I used Java's Date class ans SimpleDateFormat class to convert it to hh:mm:ss format like this:
new java.text.SimpleDateFormat("hh:mm:ss").format(new Date($F{milisec}.longValue()))
The $F{milisec} is Double so I had to convert it to long. Anyway, The problem is that the output of this expression has my local timezone added to it. So if the field's value is 10000.0, then the output would be 01:30:10 (assuming my machine's TimeZone is set to +1:30). I searched how to set the TimeZone, and I found this post:
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = isoFormat.parse("2010-05-23T09:01:02");
The thing is that I'm going to use my code as a JasperReport expression and as far as I know, I'm not allowed to use multiple lines in there. So how can I set the TimeZone of a date in java all in one line so it is considered one expression?