This content has been marked as final. Show 4 replies
Date objects don't have a format. They only contain the number of milliseconds since 1/1/1970 UTC. The name of your method does not reflect it's function and though I can see what you are trying to do it is founded on a misunderstanding of java.util.Date
No, you don't have a prolem with SimpleDateFormat.
You have a serious problem in your understanding of what a Date is (from a computers point of view).
A date is the number of milliseconds since Midnight Jan 1st, 1970 UTC. It is a number. It has no format. You use SimpleDateFormat to be able to parse a String to create this number, or to format a DateString representation of that number. You do not use it to convert a Date in one format to a date in another format because, as already said, a Date has no format.
Edit: Damn! Too slow, again!
Initially I was returning String thats why the method name is wrong.But I have changed my code and now I want to return a Date object.Ok I get that point..Date object doesn't accept format but is it possible the change the format by using SimpleDateFormat and in doing that should it always return a String not a Date object(as Date object does not have format)...??
Thanks ...yes I that was a problem in my understanding.Now it is clear.