Here you can find the source of iso8601Date(Date d)
Parameter | Description |
---|---|
d | a parameter |
public static final String iso8601Date(Date d)
//package com.java2s; /**//from w w w.j a v a 2s. co m * Copyright (C) 2011 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final String PATTERN_ISO8601 = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; /** * Return the ISO8601 string representation of a date. * * @param d * @return */ public static final String iso8601Date(Date d) { if (d == null) return null; // SDF is not thread-safe SimpleDateFormat asGMTiso8601 = new SimpleDateFormat( PATTERN_ISO8601); // with // time // zone asGMTiso8601.setTimeZone(TimeZone.getTimeZone("GMT")); return asGMTiso8601.format(d); } }