Here you can find the source of toIso8601(Date dateObj)
public static String toIso8601(Date dateObj)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final SimpleDateFormat DF = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ"); public static String toIso8601(Date dateObj) { DF.setTimeZone(TimeZone.getTimeZone("UTC")); return DF.format(dateObj).replaceAll("\\+0000$", "Z"); }//from www .j av a 2s. co m }