Format date to String in yyyy-MM-dd'T'HH:mm:ssZZZ ISO8601 format - Android java.util

Android examples for java.util:Date Format

Description

Format date to String in yyyy-MM-dd'T'HH:mm:ssZZZ ISO8601 format

Demo Code

import android.util.Log;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main{
    /** The formatter for ISO8601 */
    private static final DateFormat ISO8601_DATE_FORMATTER_TYPEII = new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ssZZZ");
    /**/*from w  ww .ja  v a 2 s .  c  o  m*/
     * Converts the Date object to the date string in the ISO 8601 format
     */
    public static final String getISO8601DateString(Date date) {

        return ISO8601_DATE_FORMATTER_TYPEII.format(date);
    }

}

Related Tutorials