Timezones and JNI/Jeode glitch. - Windows CE

This is a discussion on Timezones and JNI/Jeode glitch. - Windows CE ; We need to programmaticaly change current time zone in our application (it is run on Win CE 4.2+ Jeode JVM), we do it with code like one below. This code sets windows clock correctly, and inside the JVM all dates ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Timezones and JNI/Jeode glitch.

  1. Timezones and JNI/Jeode glitch.

    We need to programmaticaly change current time zone in our application
    (it is run on Win CE 4.2+ Jeode JVM), we do it with code like one
    below. This code sets windows clock correctly, and inside the JVM all
    dates appear to be OK. However, after serealizationon
    PPC/deserealization on PC, Date object does not show the same time and
    it is shifted exsactly by whatever bias current timezone had.
    There's no such effect if I change time zone manually. What have I
    missed?


    CODE:
    /**
    *To avoid problems with parameters and JNI and since we need only
    coupe of TZ's
    *there's separate method like this for each TZ we use.
    *
    */
    JNIEXPORT void JNICALL
    Java_com_dot_organization_core_TimeUtil_wSetGMTTTi meZone
    (JNIEnv *, jobject){

    TIME_ZONE_INFORMATION tzi;
    SYSTEMTIME stt;
    SYSTEMTIME dlt;
    LONG lRC;
    HKEY hSoftwareKey;
    HKEY hTimeKey;
    DWORD dwType;
    DWORD dwSize=sizeof(tzi);

    /*
    LONG Bias;
    WCHAR StandardName[32];
    SYSTEMTIME StandardDate;
    LONG StandardBias;
    WCHAR DaylightName[32];
    SYSTEMTIME DaylightDate;
    LONG DaylightBias;
    */
    tzi.StandardBias=0; //minutes
    tzi.DaylightBias=0;
    tzi.Bias=0;

    wcsncpy(tzi.StandardName, TEXT("GMT"),21);
    wcsncpy(tzi.DaylightName,TEXT("GMT"),21);

    /*
    MSDN:
    Day-in-month format is specified by setting the wYear member to zero,
    setting the wDayOfWeek member to an appropriate weekday, and using a
    wDay value in the range 1 through 5 to select the correct day in the
    month. Using this notation, the first Sunday in April can be
    specified,
    as can the last Thursday in October (5 is equal to the last).
    */
    stt.wYear=0;
    stt.wMonth=10;
    stt.wDayOfWeek=0;
    stt.wDay=5;//poslednee
    stt.wHour=3;
    stt.wMinute=0;
    stt.wSecond=0;
    stt.wMilliseconds=0;

    tzi.StandardDate=stt;

    dlt.wYear=0;
    dlt.wMonth=3;
    dlt.wDayOfWeek=0;
    dlt.wDay=5;
    dlt.wHour=3;
    dlt.wMinute=0;
    dlt.wSecond=0;
    dlt.wMilliseconds=0;

    tzi.DaylightDate=dlt;

    if(SetTimeZoneInformation(&tzi)==0){
    LPVOID lpMsgBuf;
    FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER |
    FORMAT_MESSAGE_FROM_SYSTEM |
    FORMAT_MESSAGE_IGNORE_INSERTS,
    NULL,
    GetLastError(),
    0, // Default language
    (LPTSTR) &lpMsgBuf,
    0,
    NULL
    );
    MessageBoxW( NULL, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK |
    MB_ICONHAND );
    // Free the buffer.
    LocalFree( lpMsgBuf );

    }
    lRC = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Time"),0,0, &hTimeKey);
    if(lRC==0){
    RegSetValueEx(hTimeKey,TEXT("TimeZoneInformation"),0,REG_BINARY,(reinterpret_cast char *>(&tzi)),dwSize);
    RegCloseKey(hTimeKey);
    }


    SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE,NULL,INI_INTL);

    }

  2. Re: Timezones and JNI/Jeode glitch.

    noir@matrixmail.net (AC.) wrote in message news:...
    > We need to programmaticaly change current time zone in our application
    > (it is run on Win CE 4.2+ Jeode JVM), we do it with code like one
    > below. This code sets windows clock correctly, and inside the JVM all
    > dates appear to be OK.


    Sorry. They're misbiased in the PDA's JVM too.

+ Reply to Thread