Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to format a date using java

Status
Not open for further replies.

Oliver76

Programmer
Oct 2, 2001
60
gud day...

i've been having problem on how to format my date to mmm-dd-yyyy. in vb6 i do it like this........... txt1.text = format(txt1,"mmm-dd-yyyy")

(i will put this in my applet)
heres my code in java:

public void paint(Graphics g) {
g.setFont(theFont); // theFont my var setup earlier
g.drawString(theDate.toString(),30,100); // theDate as well

but it gives me long date, and an "SGT" which i dont know what it means... hehehehe

tnx a lot in advance....


 

i tried to use this line of code with mine above, but it gives me error when i compile my source file... is "SimpleDateFormat" a build-in class or included in java.util.*???

formatter = new SimpleDateFormat("dd-MMM-yy");
s = formatter.format(date);
// 29-Jan-02

pls help me fix this....:)

oliver
 
You need an
Code:
import java.text.SimpleDateFormat;

If you're going to write more than a trivial amount of Java, please use the Java API Docs which are freely downloadable from Sun. You can easily get this kind information from it.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top