aspose file tools
The moose likes Beginning Java and the fly likes regarding DateFormat and  calender 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 "regarding DateFormat and  calender" Watch "regarding DateFormat and  calender" New topic
Author

regarding DateFormat and calender

Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
hi,
while i am printing the objects of DateFormat and Calendar objects,i got something surprising like this

java.text.SimpleDateFormat@ce9bf0a5 -- for DateFormat

java.util.GregorianCalendar[all fields of Calender .....] -- for Calender


why we are getting sub class names instead of Calender and DateFormat?


thanks and regards<br />Santhi Bharath<br />SCJP 5.0, SCWCD 5.0
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12928
    
    3

That's because class SimpleDateFormat does not override the toString() method from class Object, and class GregorianCalendar does.

If you print an object with System.out.println(...), then toString() will be called on the object to get a printable string.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: regarding DateFormat and calender
 
Similar Threads
How to obtain week of year for any given date
Factory Methods
Calender display
Passed SCJP 1.6 with 88%
K &B 5. 0 Errata Typo (or bug) Two Minute Drill p496