Convert string timestamp to date

How can I convert a lowercase timestamp like โ€œThu Jun 07 13:01:59 IST 2007โ€ to a date format in java ?

+4
source share
4 answers
String ds = "Thu Jun 07 13:01:59 IST 2007"; SimpleDateFormat f = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); Date d = f.parse(ds); 

As already mentioned, the answer is in the docs.

+4
source

You can use DateFormat:

 DateFormat dateFormat = new SimpleDateFormat("EM d HH:mm:ss z yyyy"); Date date = dateFormat.parse("Thu Jun 07 13:01:59 IST 2007"); 
0
source

First create a date and time pattern string as specified in the SimpleDateFormat javadocs, and then call parse to convert the string to a Date object.

-1
source

Use SimpleDateFormat . Something like that:

 DateFormat fmt = new SimpleDateFormat("EEE MMM d hh:mm:ss Z yyyy"); Date date = fmt.parse(str); 
-1
source

Source: https://habr.com/ru/post/1411246/


All Articles