Here you can find the source of format(Date date)
Format a Date object as a valid UTC Date String, per OAI-PMH guidelines http://www.openarchives.org/OAI/openarchivesprotocol.html#DatestampsResponses
Parameter | Description |
---|---|
date | Date object |
public static String format(Date date)
//package com.java2s; /**// w w w .j a va 2s . c om * The contents of this file are subject to the license and copyright * detailed in the LICENSE and NOTICE files at the root of the source * tree and available online at * * http://www.dspace.org/license/ */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** * Format a Date object as a valid UTC Date String, per OAI-PMH guidelines * http://www.openarchives.org/OAI/openarchivesprotocol.html#DatestampsResponses * * @param date Date object * @return UTC date string */ public static String format(Date date) { // NOTE: OAI-PMH REQUIRES that all dates be expressed in UTC format // as YYYY-MM-DDThh:mm:ssZ For more details, see // http://www.openarchives.org/OAI/openarchivesprotocol.html#DatestampsResponses SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); // We indicate that the returned date is in Zulu time (UTC) so we have // to set the time zone of sdf correctly sdf.setTimeZone(TimeZone.getTimeZone("ZULU")); String ret = sdf.format(date); return ret; } }