www.webdeveloper.com
Results 1 to 2 of 2

Thread: get year in java

  1. #1
    Join Date
    Feb 2006
    Posts
    98

    Exclamation get year in java

    i got the following code:

    Code:
    Date toDay = new Date();
    int year = toDay.getYear();
    System.out.println (year);
    it doesnt work. it says the year is 106.
    How do i get 2006???
    HELP?

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,122
    something along these linse will work (I am showing u the usage if date as well)

    PHP Code:
    Date cdate = new Date();
            
    Calendar gcalendar = new GregorianCalendar();
            
    gcalendar.setTime(cdate);
            
    System.out.println("cdate = "+gcalendar.toString()+"\nyear = "+gcalendar.get(Calendar.YEAR)); 
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles