Here you can find the source of timeToIso8601(long time, boolean includeTime)
public static String timeToIso8601(long time, boolean includeTime)
//package com.java2s; /**// w ww . j a va 2s .c o m * Copyright (c) 2012 Todoroo Inc * * See the file "LICENSE" for the full license governing this code. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String timeToIso8601(long time, boolean includeTime) { if (time == 0) return null; Date date = new Date(time); String formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$ if (!includeTime) formatString = "yyyy-MM-dd"; //$NON-NLS-1$ return new SimpleDateFormat(formatString).format(date); } }