Convert Date to String using simpledateformat

前端 未结 5 682
一生所求
一生所求 2021-01-16 11:29

I\'m having issues when converting a date to string in a different format. The date:

lastDownloadDate>>Wed Feb 27 16:20:23 IST 2013
lastChangeDate>&         


        
相关标签:
5条回答
  • 2021-01-16 11:58

    You have used wrong format for month.

    yyyy-mm-dd HH:mm:ss ----> yyyy-MM-dd HH:mm:ss
    mm--->Minutes. 
    MM--->Months
    
    0 讨论(0)
  • 2021-01-16 11:58

    Try

    DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    0 讨论(0)
  • 2021-01-16 12:00

    Change

    DateFormat outputFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
    

    to

    DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    0 讨论(0)
  • 2021-01-16 12:04

    yyyy-mm-dd HH:mm:ss this is wrong. This should be yyyy-MM-dd HH:mm:ss. Refer this http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html for more details regarding converting date from one format to another.

    0 讨论(0)
  • 2021-01-16 12:15
    DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    mm for Minutes
    MM for Months
    
    0 讨论(0)
提交回复
热议问题