Question: I have the following string:

```
Mon Sep 14 15:24:40 UTC 2009

```

I need to format it into a string like this:

```
14/9/2009

```

How do I do it in Java?

Answer: 
One liner in java 8 and above.

```
String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy"));

```
```
Date d = new Date("Mon Sep 14 15:24:40 UTC 2009");
SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy");
String s = new String(f.format(d));

```