Example usage for com.google.gwt.core.client JsDate getDate

List of usage examples for com.google.gwt.core.client JsDate getDate

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsDate getDate.

Prototype

public final native int getDate() ;

Source Link

Document

Returns the day of the month.

Usage

From source file:java.util.Date.java

License:Apache License

/**
 * Detects if the requested time falls into a non-existent time range due to
 * local time advancing into daylight savings time. If so, push the requested
 * time forward out of the non-existent range.
 *//*  w w w  . j a v a  2s .  c o m*/
private void fixDaylightSavings(int hours) {
    if ((jsdate.getHours() % 24) != (hours % 24)) {
        JsDate copy = JsDate.create(jsdate.getTime());
        copy.setDate(copy.getDate() + 1);
        int timeDiff = jsdate.getTimezoneOffset() - copy.getTimezoneOffset();

        // If the time zone offset is changing, advance the hours and
        // minutes from the initially requested time by the change amount
        if (timeDiff > 0) {
            int timeDiffHours = timeDiff / 60;
            int timeDiffMinutes = timeDiff % 60;
            int day = jsdate.getDate();
            int badHours = jsdate.getHours();
            if (badHours + timeDiffHours >= 24) {
                day++;
            }
            JsDate newTime = JsDate.create(jsdate.getFullYear(), jsdate.getMonth(), day, hours + timeDiffHours,
                    jsdate.getMinutes() + timeDiffMinutes, jsdate.getSeconds(), jsdate.getMilliseconds());
            jsdate.setTime(newTime.getTime());
        }
    }
}