Hi, Gora

Thanks for your advice.

and then I try to write these codes following your advice.

Case1
"pub_date" column(MySQL) is 2010-09-27 00:00:00.

I wrote like below.

SolrJDto info = new SolrJDto();
TimeZone tz2 = TimeZone.getTimeZone("UTC+9");
Calendar cal = Calendar.getInstance(tz2);
// publishDate represent "publish_date" column on Solr Schema and the
type is "pdate".
info.publishDate = rs.getDate("publish_date",cal);

then I got "2010-09-27T00:00:00Z" on Solr Admin.
This result is what I expected.

Case2
"reg_date" column(MySQL) is 2010-09-27 11:22:33.

I wrote like below.
TimeZone tz2 = TimeZone.getTimeZone("UTC+9");
Calendar cal = Calendar.getInstance(tz2);
info.publishDate = rs.getDate("reg_date",cal);

then, I got "2010-09-27T02:22:33Z" on Solr admin.
this result is not what i expected.

> As far as I know, Solr does not itself do any timezone conversion, but depends
> on the time retrieved by the driver. If you want UTC, instead of local time, 
> you
> might want to look into getDate( columnName, Calendar ).

I want to get local time(JST) on Solr Admin.

so, how do i get?

any hint please.

thx.


2010/10/5 Gora Mohanty <g...@mimirtech.com>:
> On Mon, Oct 4, 2010 at 10:24 PM, Kouta Osabe <kota0919was...@gmail.com> wrote:
>> Hi,All
>>
>> I have a problem about Solr Date Field.
> [...]
>
>> the value of pub_date column comes from MySQL and actually value is
>> "2010-10-05 00:00:00".
>>
>> I regist "foo" bean to Solr through SolrJ like "new
>> CommonsHttpSolrServer().addBean(foo)"
>>
>> I expected "2010-10-05 00:00:00" to display by Solr Admin but
>> "2010-10-04T15:00:00Z" displayed on Solr Admin.
>>
>> is this timezone problem?(I live in Tokyo Japan).
> [...]
>
> Yes, it is a timezone issue. Japan is UTC + 9h, which is the offset
> that you are seeing.
>
> As far as I know, Solr does not itself do any timezone conversion, but depends
> on the time retrieved by the driver. If you want UTC, instead of local time, 
> you
> might want to look into getDate( columnName, Calendar ). Please see
>  http://download.oracle.com/javase/1.4.2/docs/api/java/sql/ResultSet.html#getDate(int,%20java.util.Calendar)
>
> Regards,
> Gora
>



-- 
------------------------------------------------------------------
 Kouta Osabe |  kota0919was...@gmail.com

 Always Look on the Bright Side of Life!
------------------------------------------------------------------

Reply via email to