Peter Penzov Peter Penzov - 4 months ago 6
Java Question

Generate date format

I want to generate timestamp using this Java code:


What mask should I used to get the proper result?

String timeStamp = new SimpleDateFormat("").format(new Date());


Following the SimpleDateFormat Documentation (take a look at the examples) this should give you what you want:

String timeStamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+SSSS").format(new Date());

Edit: If you want the last part to be the time zone offset instead of the milliseconds, you should change the pattern to: