*
The moose likes Beginning Java and the fly likes  calendar.setTime(date) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " calendar.setTime(date)" Watch " calendar.setTime(date)" New topic
Author

calendar.setTime(date)

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hi all, I want to get the hour of day in 24hour cycle. I know that date.getHours() is depreciated. But I'm tempted to use it since I can not get the same result out of calendar.hour call.
It seems call calendar.setTime(now) does not pick up the current date value. Anybody knows what's going on here? I have the following:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Values such as c.HOUR do not return the hour of the date. They are constants used with the API to identify date fields.

Consider: c.get(Calendar.HOUR)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
I cant tell you how thankful I am! Thanks so much!
Abdul Aatif
Greenhorn

Joined: Feb 08, 2012
Posts: 23
Bear Bibeault wrote:Values such as c.HOUR do not return the hour of the date. They are constants used with the API to identify date fields.

Consider: c.get(Calendar.HOUR)


Thank you so much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calendar.setTime(date)
 
Similar Threads
java.sql.Date to java.util.Calendar
Date calculation
Create an Array of Weeks
Bug in java.util.Date.toString():?
Adding three weeks to a date