Android Date and Time Format

前端 未结 3 1296
-上瘾入骨i
-上瘾入骨i 2020-12-18 12:09

I have a sample date format Tue, 23 Aug 2011 18:33:43 +0000

In Android, I am using this statement String now = new Date().toGMTString();

3条回答
  •  自闭症患者
    2020-12-18 12:41

    Follow @MByD, except try this:

    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT");
    String formattedDate = dateFormat.format(yourDateInstance);
    

提交回复
热议问题