Converting string to date with timezone

前端 未结 5 1640
温柔的废话
温柔的废话 2020-12-05 10:58

I have a string in the pattern yyyy-MM-dd hh:mm a and i can get the time zone object separately in which the above string represents the date.

I want to convert this

5条回答
  •  死守一世寂寞
    2020-12-05 11:56

    Use SimpleDateFormat

    String string1 = "2009-10-10 12:12:12 ";
    SimpleDateFormat sdf =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z")
    sdf.setTimeZone(tz);
    Date date = sdf.parse(string1);
    

提交回复
热议问题