How to set time and date in calender class in Java?

48 views Asked by At
import java.util.*;

enum CITY{ROME,BUDAPEST,PARIS,GREECE,TALIN,AMSTREDAM,VIENNA;}

class Flight{
    private String flightName = "AirBus";
    private int ticketPrice = 50;
    private CITY Destination = CITY.ROME;
    private int numberOfTravellers = 83;
    private int flightDuration = 2;
    Calendar flightTime = Calendar.getInstance();
    Calendar flightDate = Calendar.getInstance();
    flightDate.set(Calendar.YEAR, 2002);
    flightDate.set(Calendar.MONTH, 2);
    flightDate.set(Calendar.DAY, 20);
    flightTime.set(Calendar.HOUR,10);
    flightTime.set(Calendar.MINUTE, 0);
    flightTime.set(Calendar.SECOND, 0);

    private static int goalTicketPrice = 35;
}

I am tring to set the Date and time of the flight. but getting these types of 18 errors.

It gives this error ....

<identifier> expected
    flightDate.set(Calendar.YEAR, 2002);
 
0

There are 0 answers