0

I have this

DateFormat dateFormat = new SimpleDateFormat("MM");
Date date = new Date();

I know the value as 10 but have got no idea how to print it out. How do I convert it to an int? If there even is a way?

1 Answers1

0

date.getMonth()

it is deprecated - you should be using Calendar, but if you don't want to change, that'll do it. It is 0 indexed, so remember to change the resulting value appropriately.

Javadoc

Talandar
  • 116
  • 3