-1

I'm trying to print a day of the given date. How can I do that?

String date = "2015.05.12";
SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
Date bornDate =  format.parse(date);
System.out.println(bornDate.getDay());//this prints "2" instead of "12"
xenteros
  • 15,586
  • 12
  • 56
  • 91

1 Answers1

1

You can use bornDate.getDate() to get day. You shall use calendar class as methods on date are deprecated.

Sanjeev
  • 9,876
  • 2
  • 22
  • 33