1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    4
    Vote Rating
    0
    neelepl is on a distinguished road

      0  

    Question Unanswered: Arizona Problem

    Unanswered: Arizona Problem


    In my application I am showing a window with start and end of week date.

    For that I am using the code like:
    Date start = getDate(getThisWeek(), 7 * offset + 1);
    and,
    private static Date getThisWeek() {
    Calendar calendar = Calendar.getInstance();
    //Sunday Issue
    if(calendar.getTime().getDay() == 0){
    calendar.add(Calendar.DATE, -7);
    }
    calendar.set(Calendar.DAY_OF_WEEK, 1);
    return getOnlyDate(calendar.getTime());
    }

    and,
    public static Date getDate(Date dt, int offset) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(dt);
    calendar.add(Calendar.DAY_OF_YEAR, offset);
    return getOnlyDate(calendar.getTime());
    }


    getOnlyDate method is setting the hour, min and seconds to zero.

    and offset value is 0 for current week, 1 for next week and -1 for prev week.

    So the ultimate result is like start of week is always Monday date and end of week is always Sunday.
    So on Jan 3, if we hit the system it will show the start of week as Jan 2 and end of week as Jan 8.

    But when we are changing the local machine timezone to Arizona..it is going one day back, means it is showing start of week as Jan 1 and end of week as Jan 7.

    When I am trying to debug, it is showing proper date as expected. But when the code is deployed on server and timezone is changed to Arizona it is giving the problem. For any other timezone it is showing correctly.

    Can anyone suggest any solution...I am really out of clue . Is there any way to send client timezone to server? I am using GXT framework. The server is located at Detroit(USA).

  2. #2
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Answers
    2
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    That's more a Java problem than a GWT/GXT one...

    But well, have you tried to use Calendar.getInstance() with a time zone parameter (instead of using the default, system one)? Using a reference time zone might help, if I understood correctly your issue (time zone and DST issues are always hard to fix...).

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    4
    Vote Rating
    0
    neelepl is on a distinguished road

      0  

    Default


    Using Calendar.getInstance() in server will always give the server timezone only...in my case it will be Detroit( USA), so it won't come into my help...I like to ask the same question...without prompting user to input their timezone, is there any way we can send client timezone to server?

  4. #4
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Answers
    2
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    Ah, I missed this question. To my knowledge (I just checked), the client doesn't send time information in their GET/POST requests. So, no timezone available directly.
    Perhaps your best bet is to analyze the IP address with a geo-localization service / database. Not very precise, but generaly enough for TZ info.
    Or, indeed, just ask the user.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar