Format a date String java

前端 未结 2 1577
梦如初夏
梦如初夏 2021-01-26 01:43

I have a date String like so :- Fri Oct 31 11:30:58 GMT+05:30 2014 I want to Convert it into 2014-10-31T6:00:00 which should be after adding the offset

2条回答
  •  情深已故
    2021-01-26 02:15

    This should do the task, i guess.

    public static void main(String args[]) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        System.out.println(format.format(new Date()));  
    }
    

提交回复
热议问题