Help with formatting a Date

I have some code that gets the date from an Oracle table but then when i try to display this date in my java application, I just want the date only but it also shows the time as 00:00:00...so how do i remove this time stuff from it? I looked through the API and couldnt figure it out :(

...

this.setDateLastUsed(rs.getDate("date_last_used"));

....

publicvoid setDateLastUsed(Date dateLastUsed){

this.dateLastUsed = dateLastUsed;

}

Dates show up like this: 2005-10-04 00:00:00.0

Need it to show up like: 2005-10-04

[714 byte] By [makaveli007a] at [2007-10-2 1:58:04]
# 1
Look at the String class. It has a formatter with date % things.
LumpyNosea at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 2
Use java.text.SimpleDateFormat to format it the way you want.
warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 3
> Look at the String class. It has a formatter with> date % things.That has nothing to do with the problem.
warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 4
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...) http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax
LumpyNosea at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 5
> > Look at the String class. It has a formatter with> > date % things.> > That has nothing to do with the problem.How is it any less relevant than java.text.SimpleDateFormat?I must be missing something...
yawmarka at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 6
Never mind, I prolly jumped the gun.
warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 7
hi, well i dont want to convert it to a string format. I would still like to keep it Date format for sorting purposes.
makaveli007a at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 8

> hi, well i dont want to convert it to a string

> format. I would still like to keep it Date format for

> sorting purposes.

But you ARE dealing with string formats here.

> Dates show up like this: 2005-10-04 00:00:00.0

> Need it to show up like: 2005-10-04

What do you think those bolded things are? They are strings.

warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 9
Ok, let's step back a bit...When you say the dates "show up as" something, where are they showing up in the first place? The console, from doing a System.out.println? Or what?
warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 10

> Ok, let's step back a bit...

> When you say the dates "show up as" something,

> where are they showing up in the first place?

> The console, from doing a System.out.println? Or what?

when i say "show up as" i meant to say they are showing up in your mothers hairy a-s-s. Tell her to freakin shave it.

makaveli007a at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 11

> hi, well i dont want to convert it to a string

> format. I would still like to keep it Date format for

> sorting purposes.

Everything you display on the console or in a GUI is ALWAYS converted to a String before dispaly. If you don't do it explicitly, then the methods you call will do it for you.

Note also that this doesn't transform the original object from a Date into a String. You still have your Date. It's just that now you also have a String object that represents that Date.

jverda at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 12

> > Ok, let's step back a bit...

> > When you say the dates "show up as" something,

> > where are they showing up in the first

> place?

> > The console, from doing a System.out.println? Or

> what?

>

> when i say "show up as" i meant to say they are

> showing up in your mothers hairy a-s-s. Tell her to

> freakin shave it.

Nice.

He tries to help you and you act like a jerk.

Oh, I see. You're james0007.

Okay, AR++

jverda at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 13
By the way, abuse reported on makaveli007. If I were in your shoes, I'd expect my login account to be deleted in a while.I wonder if the '007' in the username is significant?
warnerjaa at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...
# 14

> By the way, abuse reported on makaveli007. If I were

> in your shoes, I'd expect my login account to be

> deleted in a while.

> I wonder if the '007' in the username is significant?

hahaha what a snitch!! snitches dont deserve to breathe.

warnerja is a child molester, beware everybody...hide your kids

makaveli007a at 2007-7-15 19:39:18 > top of Java-index,Java Essentials,New To Java...