You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2019/04/03 12:23:03 UTC

[jira] [Commented] (DIRAPI-336) GeneralizedTime issue with timezone when DST is applied

    [ https://issues.apache.org/jira/browse/DIRAPI-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16808667#comment-16808667 ] 

Emmanuel Lecharny commented on DIRAPI-336:
------------------------------------------

There is something bizarre in your test. The first transformation uses "2019-01-23T01:23:45"{color:#333333} (no time zone), and the first output gives "{color}20190123012345+0100" when it should give {color:#333333}"{color}20190123002345+0100" (in UTC).

 

> GeneralizedTime issue with timezone when DST is applied
> -------------------------------------------------------
>
>                 Key: DIRAPI-336
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-336
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 2.0.0.AM2
>         Environment: Windows 10 pro
> JDK 1.8.0_144
> api-util 2.0.0.AM2
>            Reporter: Vitali Sidaruk
>            Priority: Major
>
> I have been facing some issues with timezone when I use GeneralizedTime. Looks like GeneralizedTime is not taking into account DST (daylight saving time) have taken place in Europe.
> After the last Sunday in March DST is applied in most European countries. I expect to see +0200 timezone offset when the date in April is converted to the string, but there is a +0100 (line 4 in output section).
> I have pasted a following code snippet, where I write date with time and timezone offset to the output from ZonedDateTime and GeneralizedTime.
>  
> {code:java}
> import org.apache.directory.api.util.GeneralizedTime;
> import java.text.SimpleDateFormat;
> import java.time.LocalDateTime;
> import java.time.ZoneId;
> import java.time.ZonedDateTime;
> import java.util.GregorianCalendar;
> ZoneId swissZone = ZoneId.of("Europe/Zurich");
> SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssZ");
> ZonedDateTime winterZonedDateTime = LocalDateTime.parse("2019-01-23T01:23:45").atZone(swissZone);
> GregorianCalendar winterCalendar = GregorianCalendar.from(winterZonedDateTime);
> System.out.println(dateFormat.format(winterCalendar.getTime()));    // 20190123012345+0100
> GeneralizedTime winterGeneralizedTime = new GeneralizedTime(winterCalendar);
> String winterGeneralizedTimeString = winterGeneralizedTime.toGeneralizedTime(
>         GeneralizedTime.Format.YEAR_MONTH_DAY_HOUR_MIN_SEC,
>         GeneralizedTime.FractionDelimiter.DOT, 1,
>         GeneralizedTime.TimeZoneFormat.DIFF_HOUR_MINUTE);
> System.out.println(winterGeneralizedTimeString);    // 20190123012345+0100
> ZonedDateTime summerZonedDateTime = LocalDateTime.parse("2019-04-03T01:23:45").atZone(swissZone);
> GregorianCalendar summerCalendar = GregorianCalendar.from(summerZonedDateTime);
> System.out.println(dateFormat.format(summerCalendar.getTime()));    // 20190403012345+0200
> GeneralizedTime summerGeneralizedTime = new GeneralizedTime(summerCalendar);
> String summerGeneralizedTimeString = summerGeneralizedTime.toGeneralizedTime(
>         GeneralizedTime.Format.YEAR_MONTH_DAY_HOUR_MIN_SEC,
>         GeneralizedTime.FractionDelimiter.DOT, 1,
>         GeneralizedTime.TimeZoneFormat.DIFF_HOUR_MINUTE);
> System.out.println(summerGeneralizedTimeString);    // 20190403012345+0100
> {code}
>  The output is
> {code:java}
> 20190123012345+0100 // winter time from ZonedDateTime 
> 20190123012345+0100 // winter time from GeneralizedTime 
> 20190403012345+0200 // summer time from ZonedDateTime 
> 20190403012345+0100 // summer time from GeneralizedTime, expected timezone offset +0200
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)