While using Calendar class of java I am getting an error, the term -Xdiags:verbos is there in error message
Code:
public class CalendarClass{
public static void main(String args[]){
Calendar cal=Calendar.getInstance();
System.out.println(cal.get(Calendar.DATE+ " / "+ Calendar.MONTH + " / " + Calendar.YEAR ));
}
}
Output:
CalendarClass.java:5: error: incompatible types: String cannot be converted to int System.out.println(cal.get(Calendar.DATE+ " / "+ Calendar.MONTH + " / " + Calendar.YEAR )); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
So how I should resolve this?
You can't create a new syntax for
Calendar.get(int)(it takes anint, not aString). Changeto
But I would strongly suggest you replace all of that with the more modern
java.timeequivalent. Like,Both of which output (because today is January 30, 2022)