Skip to content
Advertisement

Java DateTime output formatter equivalent to Calender.getInstance method

I am trying to replace old java Date with new DateTime. I am running the below code to check various formats:

JavaScript

This is the output I got :

JavaScript

I want to format the output for LocalDateTime/ZonedDateTime in such a way that it is equivalent to the Calender output. But I am unable to achieve that. Can someone help.

This is what I wish to get the output as : Fri Aug 27 13:21:29 IST 2021

Advertisement

Answer

You need to define a pattern for this specific output:

JavaScript

Defining the zone explicitly is probably not necessary on your system since it has the desired zone (mine one is different, so I had to do it).

However, the output of this was (some moments ago):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement