My input string is:
"2016-06-13T14:20:09.866Z"
My output string is:
"2016-06-13T10:20:09.866-04"
Why are they different and how can I make it output in the same format as the input?
I convert from string to date:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.ENGLISH);
dateFormat.parse((String) date));
In a unit test, I convert the parsed date back into a string:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.ENGLISH);
dateFormat.format(date);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…