Java Date Format ISO timeToIso8601(long time, boolean includeTime)

Here you can find the source of timeToIso8601(long time, boolean includeTime)

Description

time To Iso

License

Open Source License

Declaration

public static String timeToIso8601(long time, boolean includeTime) 

Method Source Code

//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);
    }
}

Related

  1. millisecondsToISO8601(long date)
  2. NowFormatISO()
  3. nowISO8601()
  4. parseISODateFormat(String dateStr)
  5. parseIsoDateTime(final String isoDateString, final String dateFormat)
  6. toBasicISO8601DateTime(Date value)
  7. toDateIso(Date date)
  8. toISO2616DateFormat(Date date)
  9. toIso8601(@Nullable Calendar calendar)