Convert String date into java.util.Date in the dd/MM/yyyy format [duplicate]

I read more questions on the web but I dont' find a solution yet.

I have a String like "14/05/1994", exactly in this format.

I need to covert it into java.util.Date in the same format.

I tried:

    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    Date dataFrom = new Date();
    dataFrom = df.format("14/05/1994");

But the result is: Sat May 14 00:00:00 CET 1994

It's possibile have as a result: 14/05/1994 not as a String, but as java.util.Date?


A java.util.Date doesn't have a format. It's just a date.

When you print it out, e.g. using toString(), it uses a default format, which is what you're seeing. But you have that date.

Date dataFrom = new Date();
dataFrom = df.format("14/05/1994");

I don't think that can be your code because DateFormat.format accepts a Date and returns a String, not the other way around. You might mean df.parse, which would get you the results you describe. But if you take your SimpleDateFormat and use its format method on the Date, then you should get back out 14/05/1994 as you want. A java.util.Date doesn't have a format, though.