Gregorian Calendar Error

Discussion in 'Java' started by Lunight Sitaki, Oct 2, 2006.

  1. Lunight Sitaki

    Lunight Sitaki

    Joined:
    Oct 2, 2006
    Messages:
    1
    Well I'm writing a school project and my compiler keeps telling me a line is wrong with the errors ".class expected" and ")" expected. We are required to use the Gregorian calendar and so far this is what I have.

    package craijwlab2;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import javax.swing.JOptionPane;



    public static void main(String[] args) {
    GregorianCalendar cal = new GregorianCalendar();

    cal.add(Calendar.MONTH, 1);


    JOptionPane.showMessageDialog(null, "Todays date is "+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.DATE)+"/"+cal.get(Calendar.YEAR));

    String birthMonth;
    birthMonth = JOptionPane.showInputDialog("Which month number were you born in?:");
    int month = Integer.parseInt(birthMonth);

    String dayOfBirth;
    dayOfBirth = JOptionPane.showInputDialog("Which day of the month were you born?:");
    int date = Integer.parseInt(dayOfBirth);

    String birthYear;
    birthYear= JOptionPane.showInputDialog("What is the year of your birth:");
    int year = Integer.parseInt(birthYear);

    **GregorianCalendar birthday= new GregorianCalendar(int month, int date, int year);**

    JOptionPane.showInputDialog("So your birthday is "+(birthday)+"?");
    }

    }

    The line with the stars around it is the one with the errors but maybe I'm missing something in the code? Thanks in advance. The aim of this project is to get the information from the user about their birthday and then use it and today's date to get their age.
    Last edited: Oct 2, 2006
    Lunight Sitaki, Oct 2, 2006
    #1
    1. Advertising

  2. Lunight Sitaki

    mosborn

    Joined:
    Sep 20, 2006
    Messages:
    7
    Location:
    Bowling Green, OH, USA
    First, in your example you're missing your class declaration, e.g.

    public class Foo { ...

    Assuming that's just a typo, since you're getting actual compiler errors, in your ** ... ** line, take out the "int"s. You use those when you declare or define a new method, not when you call one (the GregorianCalendar constructor in this case). You only need to pass in the variable...

    GregorianCalendar birthday= new GregorianCalendar(month, date, year);

    If what you're passing in isn't an int, the compiler will complain.

    Good luck.
    mosborn, Oct 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. h_ghanaty

    convert gregorian date to jalay date

    h_ghanaty, Nov 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    527
    Bret Mulvey [MS]
    Nov 9, 2003
  2. Shevek
    Replies:
    3
    Views:
    6,032
    Shevek
    Jun 23, 2004
  3. =?Utf-8?B?Q2hyaXMgRGF2b2xp?=

    Gregorian to Julian Date conversion

    =?Utf-8?B?Q2hyaXMgRGF2b2xp?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,463
    Mark Rae
    Feb 3, 2005
  4. Sam
    Replies:
    1
    Views:
    5,127
    Pete Davis
    Apr 27, 2005
  5. Afanasiy

    ISO to Gregorian, strptime madness

    Afanasiy, Dec 4, 2003, in forum: Python
    Replies:
    4
    Views:
    435
    Peter Hansen
    Dec 4, 2003
Loading...

Share This Page