Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

DateFormat Class Problem

 
Ranch Hand
Posts: 88
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...I was trying to play around with Kathy's given example on DateFormat Class in her SCJP book (page 480) but getting these following errors (Line 12, 13 and 16). Where is my mistake?


For line-12: It is showing this error: "The method getInstance() is undefined for the type DateFormat"
For line-13: It is showing this error: "DateFormat.SHORT cannot be resolved" AND
for line-16: It is showing this error: "The method format(Date) is undefined for the type DateFormat"

Any help please...

My Java Version is as follows:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
 
Faisal Fuad
Ranch Hand
Posts: 88
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry everyone....it was my Bad....I defined the Class name as the same name of the DateFormat Abstract class....and thats why compiler was complening. As soon as i changed my Class name, everything started running.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, I made two changes to make it work -

-- typo


-- avoiding null pointer exception


Regards,
Dan

 
permaculture is largely about replacing oil with people. And one tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic