Description
Using simple date format "yyyy-MM-dd-HH-mm", startTime 01-01-2015 will get formatted to 2015-01-01-00-00 on a server / developer machine running with UTC time zone where as the same will be formatted to 2015-01-01-05-30 on a server / developer machine running in IST.
A test case which is expecting 2015-01-01-00-00 as a result of formatting will run fine in UTC time zone and will fail when the same is run on a machine in some other time zone. Test case can be made more generic by creating expected formatted string in local time zone but thats just adding un-required complexity to test case.
Also changing displayed time strings based on client time zone can be a requirement but changing the same based on the time zone of the machine (server) on which code is run seems to be an undesired behavior.
One of the ways to fix this is to create SimpleDateFormat instance with time zone as UTC and consistently use UTC everywhere to keep things simple:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));