Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.Calendar

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got an error message saying:
Cannot assign value of type 'java.lang.String' to property 'last_logon_date' of type 'java.util.Calendar'
What value I should give that is of type 'java.util.Calendar'?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the doc for the set( field, value) method. You can set individual year, month, day, hour, minute, second fields. A major pain.
If you have a string date in a known format, you can use the DateFormat class to parse it and create a Date, then setTime on the Calendar. I find the date handling in Java very icky (set TIME indeed!) and always code this stuff with the JDK doc open.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not explain my problem better. Sorry.
I have a form for users to fill out the text field. I specify the field as of java.util.Calendar type.
During testing, I filled out the text field with a date in various ways (for example, 06/27/2003, June 27, 2003, etc.) The computer always gave an error message saying the information I had given was of String type.
Therefore, I am wondering what value is of java.util.Calendar type.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to convert your String to a java.util.Calendar.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for advices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic