-6

On my DB i have a date column with this format: '2016-10-05'

How can i obtain the actual date on this format?

I tried with

Date date = new Date();

But the format is not compatible and it doesen't works.

Removed
  • 109
  • 3
  • 19

1 Answers1

0
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(stringWithDate);

You have to use SimpleDataFormat which allows you to parse Strings with different formats to Date

xenteros
  • 15,586
  • 12
  • 56
  • 91
  • 4
    why you are answering duplicate questions? – SpringLearner Oct 05 '16 at 08:58
  • To help new user who might help the others in a very future. – xenteros Oct 05 '16 at 09:00
  • 1
    But there are many questions similar to this and it has been answered. It is against the stackoverflow to have duplicate questions. If you want to help new user then please answer new questions. If you know have a different answer for a duplicate question then please answer in the old question and do not answer in the duplicated question – SpringLearner Oct 05 '16 at 09:03