DateTools question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

DateTools question

wsnyder6
Hello,

Why does DateTools.dateToString() return a String representation of my Date,
but in a different TimeZone. Does it use its own Calendar/TimeZone settings?

F.I.

DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
System.out.println(DateTools.dateToString(format.parse("2006-04-26 07:29:
52.581"),DateTools.Resolution.MINUTE));

will print out

200604261129

Why the 4 hour difference?

Thanks!

--Bill
Reply | Threaded
Open this post in threaded view
|

Re: DateTools question

Chris Hostetter-3

: Why does DateTools.dateToString() return a String representation of my Date,
: but in a different TimeZone. Does it use its own Calendar/TimeZone settings?

Yes, DateTime is hardcoded to use GMT for it's string representations.

It wouldn't be safe for DateTools to use your current TimeZone/Locale,
because once you've indexed the value, your index might be used by another
application (or another instance of your application) running in a
differnet locale.

The important thing is not what string DateTools.dateToString returns,
it's whether you get an equivilent date back (based on the resolution you
specified)) when you do something like this...

  Date a = ...;
  DateTools.Resolution r = ...;
  Date b = DateTools.stringToDate(DateTools.dateToString(a,r));
  System.out.println("Is '"+a+"' the same as '"+b+"' with "+r+" resolution?");


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

How to display a field value

anton feldmann
In reply to this post by wsnyder6
Hi

how do i display the whole field value of an document the query string
is found?

cheers

anton

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: DateTools question

wsnyder6
In reply to this post by Chris Hostetter-3
Makes sense. Thanks for the response!

--Bill

On 4/26/06, Chris Hostetter <[hidden email]> wrote:

>
>
> : Why does DateTools.dateToString() return a String representation of my
> Date,
> : but in a different TimeZone. Does it use its own Calendar/TimeZone
> settings?
>
> Yes, DateTime is hardcoded to use GMT for it's string representations.
>
> It wouldn't be safe for DateTools to use your current TimeZone/Locale,
> because once you've indexed the value, your index might be used by another
> application (or another instance of your application) running in a
> differnet locale.
>
> The important thing is not what string DateTools.dateToString returns,
> it's whether you get an equivilent date back (based on the resolution you
> specified)) when you do something like this...
>
>   Date a = ...;
>   DateTools.Resolution r = ...;
>   Date b = DateTools.stringToDate(DateTools.dateToString(a,r));
>   System.out.println("Is '"+a+"' the same as '"+b+"' with "+r+"
> resolution?");
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>