Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Timezone conversion with setDefaultDisplayTimezone

$
0
0
Hello,

I have some issues with timezones. My server is running with GMT+2:00 (Berlin). Now I have a client which is running under GMT+1:00 (London). I want to disable the timezone conversion from GMT+2:00 to GMT+1:00. So that the GMT+1:00 client uses GMT+2:00 as timezone

I found the method "DateUtil.setDefaultDisplayTimezone( "+2:00" ); This seems not to work for me

Using a client with timezone GMT+1:00 still converts the time from GMT+2:00 to GMT+1:00

Example:
Code:

public void onModuleLoad()
{
        final String DATE_TIME_PATTERN = "dd.MM.yyyy HH:mm";
        final DateTimeFormat dateFormat = DateTimeFormat.getFormat( "dd.MM.yyyy" );
        final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( DATE_TIME_PATTERN );

        DateDisplayFormatter dateFormatter = new DateDisplayFormatter()
        {
            @Override
            public String format( Date date )
            {
                String form = dateFormat.format( date );
                return form;
            }
        };
        DateDisplayFormatter datetimeFormatter = new DateDisplayFormatter()
        {
            @Override
            public String format( Date date )
            {
                String form = dateTimeFormat.format( date );
                return form;
            }
        };

        // Sets the Default date Seperator System wide
        DateUtil.setDefaultDateSeparator( "." );
        DateUtil.setNormalDateDisplayFormatter( dateFormatter );
        DateUtil.setShortDateDisplayFormatter( dateFormatter );
        DateUtil.setShortDatetimeDisplayFormatter( datetimeFormatter );
        DateUtil.setDateParser( new DateParser()
        {
            public Date parse( String dateString )
            {
                final DateTimeFormat format = DateTimeFormat.getFormat( DATE_TIME_PATTERN );
                Date date = format.parse( dateString );
                return date;
            }
        } );
       
        // Sets the timezone
        TimeZoneConstants timeZoneConstants = GWT.create( TimeZoneConstants.class );
        TIMEZONE = TimeZone.createTimeZone( TimeZoneInfo.buildTimeZoneData( timeZoneConstants.europeBerlin() ) );
        timezoneGmt = TIMEZONE.getGMTString( new Date() ).replace( "GMT", "" );
        DateUtil.setDefaultDisplayTimezone( timezoneGmt );
        String zoneClient = DateTimeFormat.getFormat( "ZZZ" ).format( new Date() );

            SC.say( "Timezone Client: " + zoneClient + "<br>Timezone Server: " + timezoneGmt );
}


Viewing all articles
Browse latest Browse all 4756

Trending Articles