Android Time Format getRFC3339FormattedTime()

Here you can find the source of getRFC3339FormattedTime()

Description

get RFC Formatted Time

Declaration

public static String getRFC3339FormattedTime() 

Method Source Code

//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import java.util.Locale;

public class Main {
    public static String getRFC3339FormattedTime() {

        Calendar calendar = getCurrentCalendar();
        calendar.add(Calendar.HOUR_OF_DAY, -9);
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ssz");
        String result = format.format(calendar.getTime());
        String standardName = "";
        if (result.contains("JST")) {
            standardName = "JST";
            result = result.replaceAll(standardName, "+09:00");
        } else if (result.contains("GMT")) {
            standardName = "GMT";
            result = result.replaceAll(standardName, "");
        }/*from  ww  w.j  a v  a  2s.com*/
        return result;
    }

    public static Calendar getCurrentCalendar() {

        Calendar currentCal = new GregorianCalendar(Locale.JAPAN);

        return currentCal;
    }
}

Related

  1. formatTime(long time)
  2. convertDateTime(String date, String format)
  3. convertDateTime(long date, String format)
  4. getDateFromFormattedTimeStamp( String formattedTimeStamp)
  5. getFormattedTimeStamp(long millisSince1970)
  6. get_current_date_time_format1_str()
  7. timeFormatToString(int paramInt)
  8. timeLongToHhmm(long timeMillis, DateFormat df)
  9. toModifiedTimeString(Date modified)