-3

I'm typing this code:

import java.util.Calendar;  //Required to get the instance of date on the computer
import java.util.Date;      //Required if you want to store instances of the calendar in a varaible
import java.util.Scanner;   //Required to collect input from the user


public class L01ManagingDate 
{

    public static void main(String[] args)
    {


    Calendar cal = Calendar.getInstance();  

    System.out.println(cal);    

    System.out.println("The current date list printed out, but not stored " + cal.getTime());

    Date dateNow = cal.getTime();   
    System.out.println("The current date list stored in a variable " + dateNow);

    System.out.printf("%-22s %d%n" , "Year" , cal.get(Calendar.YEAR));
    System.out.printf("%-22s %d%n" , "Month" , cal.get(Calendar.MONTH));
    System.out.printf("%-22s %d%n" , "Month" , cal.get(Calendar.DAY_OF_MONTH));
    System.out.printf("%-22s %d%n" , "Week" , cal.get(Calendar.DAY_OF_WEEK));
    System.out.printf("%-22s %d%n" , "Day" , cal.get(Calendar.DAY_OF_YEAR));
    System.out.printf("%-22s %d%n" , "Week" , cal.get(Calendar.WEEK_OF_YEAR));
    System.out.printf("%-22s %d%n" , "Month" , cal.get(Calendar.WEEK_OF_MONTH));
    System.out.printf("%-22s %d%n" , "Day of week in month" , cal.get(Calendar.DAY_OF_WEEK_IN_MONTH));
    System.out.printf("%-22s %d%n" , "AM (0) or PM (1)" , cal.get(Calendar.AM_PM));
    System.out.printf("%-22s %d%n" , "Hour" , cal.get(Calendar.HOUR_OF_DAY));
    System.out.printf("%-22s %d%n" , "Minute" , cal.get(Calendar.MINUTE));
    System.out.printf("%-22s %d%n" , "Second" , cal.get(Calendar.SECOND));
    System.out.printf("%-22s %d%n" , "Millisecond" , cal.get(Calendar.MILLISECOND));

And i got this error on all my print Fs The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, String, int) Please help

1 Answers1

-1

change every statement to look like this. don't pass a second argument as string see here

 System.out.printf("%-22s %d%n Year" , cal.get(Calendar.YEAR));
Krishna
  • 529
  • 3
  • 13