Im trying to format a Date
to String
using SimpleDateFormat
, and the pattern im using is this one
"yyyy-MM-dd'T'HH:mm:ss.SSSxxx"
but when reach this line
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSxxx");
i get the following exception:
java.lang.IllegalArgumentException: Unknown pattern character 'x' at java.text.SimpleDateFormat.validatePatternCharacter(SimpleDateFormat.java:323) at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:312) at java.text.SimpleDateFormat.(SimpleDateFormat.java:365) at java.text.SimpleDateFormat.(SimpleDateFormat.java:258)
the format im trying to achieve is "2017-06-16T12:19:59.001+02:00"
according to the documentation this pattern should work Whats wrong?
EDIT To clarify, i tried with xxx and XXX
in case of XXX i get java.lang.IllegalArgumentException: Unknown pattern character 'X'
X
, while documentation tells that it should be lowercasex
. But then exception stack tells about lowercasex
again. Can you please clarify that? – ObligationX
. I have no idea why people wanna down vote this question for no reason. I'm gonna give this question an up-vote. – Swinney