Skip to content

Instantly share code, notes, and snippets.

@helloanoop
Created August 25, 2016 23:03
Show Gist options
  • Select an option

  • Save helloanoop/aa86e644fed94db94ec53c85a2120e8e to your computer and use it in GitHub Desktop.

Select an option

Save helloanoop/aa86e644fed94db94ec53c85a2120e8e to your computer and use it in GitHub Desktop.
DateFormatter Example in Java
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