Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Programmer Certification (OCPJP)
DateFormat question
adam Lui
Ranch Hand
Posts: 186
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
1. import java.text.*; 2. class DateOne { 3. public static void main(String[] args) { 4. Date d = new Date(1123631685981L); 5. DateFormat df = new DateFormat(); 6. System.out.println(df.format(d)); 7. } 8. }
in order to successfully print that Date, I am trying to fix this code. (question copied from K&B book, chapter 6, p511)
can you help me to fix? this topic is still really confusing me!
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Class DateFormat is an abstract class. You cannot instantiate an abstract class, as you are doing in line 5 of your code. Replace line 5 with something like this:
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
And you also need to import java.util.Date.
Jesper's Blog
-
Pluralsight Author Page
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
DateFormat class
date format problem
How to guess exception
Date format question
Time difference
More...