Android Format date with time zone

前端 未结 8 1376
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 13:05

I need to format the date into a specific string.

I used SimpleDateFormat class to format the date using the pattern \"yyyy-MM-dd\'T\'HH:m

8条回答
  •  孤街浪徒
    2020-12-10 13:49

    You can also use "ZZZZZ" instead of "Z" in your pattern (according to documentation). Something like this

        Calendar c = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.ENGLISH);      
        Log.e(C.TAG, "formatted string: "+sdf.format(c.getTime()));
    

提交回复
热议问题