Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2007, 03:54 AM
Member
 
Join Date: Jul 2007
Location: Fairfield, IA 52557
Posts: 2
tola.ch2004 is on a distinguished road
Send a message via Skype™ to tola.ch2004
Problem with "GregorianCalendar"
I initialize object of Gregorian class by the following code:
Code:
GregorianCalendar greCal = new GregorianCalendar(2000, 2, 1);
And display it by the following code:
Code:
System.out.println(greCal.getTime().getMonth() + "/" + greCal.getTime().getDate() + "/" + greCal.getTime().getYear());
Asa result I got:
2/1/100 (It is Wrong!)
It should be 2/1/2000

Anyone please tell me why?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-12-2007, 05:53 PM
Member
 
Join Date: Jul 2007
Posts: 44
susan is on a distinguished road
Try with this code:
Code:
DateFormat dateFormat = DateFormat.getDateInstance(); Date date = dateFormat.parse("2000-01-02"); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(date);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-12-2007, 09:12 PM
Member
 
Join Date: Jul 2007
Location: Fairfield, IA 52557
Posts: 2
tola.ch2004 is on a distinguished road
Send a message via Skype™ to tola.ch2004
Yes, it worked. Thank guy.

However it made me feel uncomfortable with this GregorianCalendar.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Displayed tab width" problem... Petike Eclipse 0 03-17-2008 10:39 PM
I have a problem with variable "i" silvia New To Java 2 08-08-2007 12:05 AM
Hwlp with "Open", "Save", "Save as..." trill New To Java 1 07-31-2007 08:53 AM
Exception in thread "main" java.net.ConnectException: Connection timed out osval Advanced Java 1 07-27-2007 11:59 PM
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException romina New To Java 1 07-25-2007 11:55 PM


All times are GMT +3. The time now is 10:45 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org