tommysiu / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 0 forks source link

Improvement for datetime parsinf in different timezones. #125

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?  If applicable, please provide a
mapping configuration and sample record input to recreate the problem.
1. Create mapping to file containing Date in UTC+2.
2. System default timezone is UTC+7
3. DateTime.getTime from file and DateTime.getTime() after file processing is 
different

What is the expected output? What do you see instead?
DateTime parsing in correct timezone. I want to specify timezone I have in file 
for correct processing for case when I have a lot of files with different 
timezones or two dates in different timezones in a file.

What version of BeanIO are you using? What JDK version?
BeanIO 2.1.0 JDK 1.7

Please provide any additional information below.
Fix attached for Joda implementation because it has wider support of patterns. 
It's better to have separate property in config to specify datetime timezone.

Original issue reported on code.google.com by DmitryKa...@gmail.com on 24 Oct 2014 at 12:24

Attachments:

GoogleCodeExporter commented 8 years ago
You can set the time zone on a date type handler using the property 
'timeZoneId'.

Joda based date/time type handlers will not be included in the library, but can 
be easily implemented by users.

Original comment by kevin.s...@gmail.com on 5 Nov 2014 at 2:19

GoogleCodeExporter commented 8 years ago
Thank you. I've found out that already. I had to create type handler to set 
timeZoneId
    <typeHandler class="org.beanio.types.DateTypeHandler" name="UTCTimeHandler">
        <property name="timeZoneId" value="UTC"/>
    </typeHandler>

Original comment by DmitryKa...@gmail.com on 5 Nov 2014 at 10:26