• Post Reply Bookmark Topic Watch Topic
  • New Topic

shortening the TimeStamp to just the year/month/day?  RSS feed

 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method available to our JSF front-end that shows the Date (timestamp) that an order takes place.
The expression is

I want to strip it down to just the date and not use the hours, minutes, and seconds.

So in the CustomerOrder class (it's superclass is customerSession) I want to create a method to do this.

At the top of the class I define a private Date variable because I see orderTS is there as well... :


I then define getters and setters..



Is this correct so far?

If it is how would I go about shortening the orderTs to just the year/month/day?

 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to format the Date as a string in the format YYYY/MM/DD (or any other format) then a SimpleDateFormat object can do that for you.

If you mean something else than producing a String, then you would have to explain what type of data you wanted to produce instead of a Date.
 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:If you want to format the Date as a string in the format YYYY/MM/DD (or any other format) then a SimpleDateFormat object can do that for you.


Hi Paul.

Can I just that on the front end in / around the JSF EL expression or do I need to do it in the orderTSShort method I am trying to create?


Thanks,
Dan
 
Bert Wilkinson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are misusing the Date variable. The Date variable is a value that represents the a specific time (year/mo/date/time) in miliseconds from a reference point. It doesn't make sense to talk about a "shortened" version of the Date. When you output the date, you should use the formatter mentioned above to display/print the portion or format you desire for that instant in time

there's plenty of examples on the javadoc for SimpleDateFormatter

something like

 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

It turns out I can just use SEAM to change the pattern of the date.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!