Simple date formatting giving wrong time

后端 未结 4 1749
暗喜
暗喜 2021-01-20 05:57

I am trying to parse a String to a Date and it giving me right date where as time is wrong.

SimpleDateFormat formatter = new SimpleDateFormat(\"yyyy-MM-dd HH         


        
4条回答
  •  天命终不由人
    2021-01-20 06:28

    Try this code you missed some lines of code

    SimpleDateFormat mFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm aa",  Locale.getDefault());
    mFormatter.setTimeZone(TimeZone.getTimeZone("India"));
    Date startDate = mFormatter.parse("2015-08-20 05:00 AM");
    

    This code working fine for me.

提交回复
热议问题