V
V
vitya_brodov2022-04-21 06:35:37
Java
vitya_brodov, 2022-04-21 06:35:37

How to parse a date into the correct format in Java?

I have a date in the form : Tue Apr 19 00:00:00 ALMT 2022
how can I parse it into the format 19/04/2022?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2022-04-21
@vitya_brodov

var s = "Tue Apr 19 00:00:00 ALMT 2022";
        var format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);
        var date = format.parse(s);
        var newFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
        var formatedDate = newFormat.format(date);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question