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
Look at the String class. It has a formatter with date % things.
Use java.text.SimpleDateFormat to format it the way you want.
> Look at the String class. It has a formatter with> date % things.That has nothing to do with the problem.
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
> > 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...
Never mind, I prolly jumped the gun.
hi, well i dont want to convert it to a string format. I would still like to keep it Date format for sorting purposes.
> 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.
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?
> 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.
> 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 >

> > 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 >

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?
> 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