I have code that works,
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
String today = (year + "" + (month + 1) + "" + day + "-");
System.out.println("Current date : " + today);
But, where the day of the month is 1 to 9 this will display the digit without the leading zero.
I have tried to use length() to check the size but I get an error that this is not allowed.
Is there a easy fix?
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
String today = (year + "" + (month + 1) + "" + day + "-");
System.out.println("Current date : " + today);
But, where the day of the month is 1 to 9 this will display the digit without the leading zero.
I have tried to use length() to check the size but I get an error that this is not allowed.
Is there a easy fix?