my dog learned polymorphism*
The moose likes Beginning Java and the fly likes setting calendar to an arbitrary date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting calendar to an arbitrary date" Watch "setting calendar to an arbitrary date" New topic
Author

setting calendar to an arbitrary date

Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

This code does not work because there is no set method for Calendar and setTime errs because it's a non-static method.
Is setting up GregorianCalendar the simplest way to set Calendar given an input string "M/d/yy"?



Thank you.


String knock = "\u042F \u0418\u0433\u043e\u0440\u044c";
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You'll need a Calendar object to start with. If you read the documentation for java.util.Calendar it tells you in the introduction exactly how to do that.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Ilya Mechnikov wrote:

So why not create an instance using Calendar.getInstance()?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

I got this to work



Thank you for your help.
 
Consider Paul's rocket mass heater.
 
subject: setting calendar to an arbitrary date
 
Similar Threads
Any Alternative for this CODE !!!!!!
date manipulation
Calendar Class
Possble Calendar bug with daylight saving time
Calendar Object to String