![JAR search and dependency download from the Maven repository](/logo.png)
org.sakaiproject.genericdao.util.DateUtils Maven / Gradle / Ivy
/**
* $Id$
* $URL$
* DateUtils.java - genericdao - Sep 16, 2008 11:03:28 PM - azeckoski
**************************************************************************
* Copyright (c) 2008 Aaron Zeckoski
* Licensed under the Apache License, Version 2.0
*
* A copy of the Apache License has been included in this
* distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Aaron Zeckoski (azeckoski @ gmail.com) (aaronz @ vt.edu) (aaron @ caret.cam.ac.uk)
*/
package org.sakaiproject.genericdao.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* Date conversion utilities, mostly for outputing dates in standard formats
*
* @author Aaron Zeckoski (azeckoski @ gmail.com)
*/
public class DateUtils {
public static String makeDateRFC2822(Date date) {
SimpleDateFormat df = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);
return df.format(date);
}
public static String makeDateISO8601(Date date) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
String result = df.format(date);
// convert YYYYMMDDTHH:mm:ss+HH00 into YYYYMMDDTHH:mm:ss+HH:00
result = result.substring(0, result.length() - 2) + ":" + result.substring(result.length() - 2);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy