This is because your Locale timezone, to achieve what you need, converts the date using SimpleDateFormat :
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
UPDATE when you comment:
I tried formatting it to String, and then parse it back to Date. Then set the time in the Calender object. Does not work. However, I get the output as "2015-04-15T11: 04: 30.000Z"
You should understand that Calendar or Date objects are stored in its own format, another thing is how you print them, so in this case, seeing 2015-04-15T11:04:30.000Z in the Calendar view does not matter, you need to have the correct date 2015-04-15 at 11:04:30 to show it in the right format to make your conclusion more convenient.
You get the result from Calendar.toString () , and the doc doc says:
Returns a string representation of this calendar. This method is intended for use only for debugging purposes, and the format of the returned string may vary depending on the implementation . The returned string may be empty, but may not be null.
So, to save the date and time, your Calendar object is correct. To print it, you must convert it to String .
source share