aspose file tools
The moose likes Beginning Java and the fly likes Getting time from Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Getting time from Calendar" Watch "Getting time from Calendar" New topic
Author

Getting time from Calendar

John Faulk
Greenhorn

Joined: Feb 05, 2001
Posts: 4
hi, i am trying to figure out if the time has been set in the calendar. isSet returns true if the hour is 0 assuming it is midnight. so when does it return false.
-----------------------------------------------------------
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date d = sdf.parse("20010909", new ParsePosition(0));
System.out.println("t/f " + c.isSet(Calendar.HOUR) );
-----------------------------------------------------------
the above returns true because the hour is 0. so when will it return false???
John Faulk
Greenhorn

Joined: Feb 05, 2001
Posts: 4
yes i did do a c.setTime(d); after getting Date d.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Per the API

isSet()
The flags which tell if a specified time field for the calendar is set. A new object has no fields set. After the first call to a method which generates the fields, they all remain set after that. This is an array of FIELD_COUNT booleans, with index values ERA through DST_OFFSET.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting time from Calendar
 
Similar Threads
equals() method
48 hours rule, pls recomment
timezone woes
Output a Calendar with timezone, in W3C datetime format?
Converting to UTC time zone