• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Time Format  RSS feed

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to generate current date and time format like “2008-09-29T07:19:45”. Please assist me
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at JavaDatesFaq. It has everything which will help you solve your problem.

Update: You would have to use SimpleDateFormat and specify a format you want.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I tried this... SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

But I need "T" before time.. Pelase help
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the documentation a bit more. Then you should come up with something like this:

I say "something like" because I didn't check that with what the documentation really says. So you should check it.
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meet Gaurav wrote:
... But I need "T" before time.. Pelase help


That T is the Timezone information. So in the format you are passing to the SimpleDateFormat you need to add the Timezone information.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Sanaulla wrote:That T is the Timezone information.

Well no, actually that T is just a literal letter T. The timezone information comes right after. But Paul C has already pointed towards the best source of information about this...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!