• Post Reply Bookmark Topic Watch Topic
  • New Topic

simpledateformat  RSS feed

 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a date format of yyyy-MM-dd-HH.mm.ss.SSSSSS and need to convert it to yyyy-MM-dd HH:mm:ss.S

but say when i pass the date 2010-02-16-23.59.59.999000 i m getting the formated date as 2010-02-17 00:16:38.000

 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This I think is due to the different TIMEZONE. You can look at the SimpleDateFormat API to see the format for specifying the Timezone.
 
Prakash Krsihnan
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milliseconds is always three digit. Even if "SSSSSS" is given
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I told suggested to check with TIMEZONE as there was a difference between the 2 dates (~16 minutes if I am not wrong).

Update: and it looks like a difference of 1 day
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash is right. You probably expect the 999000 to be read as 999, but it is read as 999000, then truncated to 0 (999000 % 1000 == 0).
 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But why is the date incrementing by 1 day.
 
Prakash Krsihnan
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you convert "999000" ms to minute it comes to 17:38 and it added to date.
It advisable to use only SSS or S. Don't use more than three S for microseconds
 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash Krsihnan wrote:If you convert "999000" ms to minute it comes to 17:38 and it added to date.
It advisable to use only SSS or S. Don't use more than three S for microseconds


Thank you very much
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash Krsihnan wrote:If you convert "999000" ms to minute it comes to 17:38 and it added to date.
It advisable to use only SSS or S. Don't use more than three S for microseconds

Oh nice catch. It struck to me as a TIMEZONE issue.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash Krsihnan wrote:If you convert "999000" ms to minute it comes to 17:38 and it added to date.
It advisable to use only SSS or S. Don't use more than three S for microseconds

So I was wrong - the 999000 isn't truncated at all but added as additional milliseconds.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!