Created
August 25, 2016 23:03
-
-
Save helloanoop/aa86e644fed94db94ec53c85a2120e8e to your computer and use it in GitHub Desktop.
DateFormatter Example in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.format.DateTimeFormatter; | |
| import java.util.Date; | |
| import java.time.Instant; | |
| import java.time.ZoneId; | |
| import java.time.ZonedDateTime; | |
| public class DateFormatter{ | |
| public static void main(String []args){ | |
| System.out.println("Hello World 2"); | |
| ZoneId zone1 = ZoneId.of("Europe/Berlin"); | |
| ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.now(), zone1); | |
| String formattedDateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy_HH-mm-ss").format(zonedDateTime); | |
| System.out.println(formattedDateTime); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment