Here you can find the source of formatDate(ZonedDateTime dt)
public static String formatDate(ZonedDateTime dt)
//package com.java2s; //License from project: Open Source License import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; public class Main { public static String formatDate(ZonedDateTime dt) { DateTimeFormatter fmt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneOffset.UTC); return fmt.format(dt.truncatedTo(ChronoUnit.SECONDS)); }// www.ja v a 2 s. c om }