Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I import SimpleDateFormat?

 
Sheldon Plankton
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bash-2.03$ cat TimeStamp.java

bash-2.03$ javac -verbose TimeStamp.java
[parsing started TimeStamp.java]
[parsing completed 221ms]
[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/lang/Object.class)]
[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/lang/String.class)]
[checking TimeStamp]

[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/lang/System.class)]
[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/io/PrintStream.class)]
[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/io/FilterOutputStream.class)]
[loading /usr/local/home/Plankton/SUNWappserver/jdk/jre/lib/rt.jar(java/io/OutputStream.class)]
[total 1210ms]
2 errors
bash-2.03$ env | grep CLASS
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ February 15, 2004: Message edited by: Dirk Schreckmann ]
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sheldon
Use,
import java.text.*;
and you should be fine..
Regards
Maulin
 
Sheldon Plankton
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! What should of clued me into the fact that I imported the wrong package? That's seems to be a source of frustration for me.
 
Alex Cano
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sheldon Plankton:
Thanks! What should of clued me into the fact that I imported the wrong package? That's seems to be a source of frustration for me.

A few things that might make your life less frustrating (in order of least time consuming):
1) Using an IDE that figures this stuff out for you (Eclipse is a great IDE and it's free)
2) Looking up package information in relavant code documentation
3) Googling for this type of info
I strongly recommend going with option 1) and using the rest as backups.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a new Java programmer is starting to learn the language and the standard libraries, I'd recommend not using a fancy IDE, which could hide some fundamental things that are good to know and understand. When the basics are understood and mastered, it's probably a safe and good time to move onto an advanced IDE.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic