SimpleDateFormat with TimeZone

前端 未结 6 916
旧巷少年郎
旧巷少年郎 2020-12-06 00:56

I\'m trying to format date from java.util.Date. I need this format:

2016-06-10T13:38:13.687+02:00.

How correctly convert this from standard Da

6条回答
  •  被撕碎了的回忆
    2020-12-06 01:37

    Just turn your z to upperCase

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z", Locale.getDefault());
        sdf.format(new Date());
    

    Result: 2016-06-10T13:53:22 +0200

提交回复
热议问题