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

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

Introduction

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

Prototype

public final native double getTime() ;

Source Link

Document

Returns the internal millisecond representation of the date, the number of milliseconds since midnight on January 1st, 1970.

Usage

From source file:com.google.web.bindery.autobean.shared.impl.StringQuoter.java

License:Apache License

public static Date tryParseDate(String date) {
    try {/*from   w  ww.  j a v  a  2 s .  co m*/
        return new Date(Long.parseLong(date));
    } catch (NumberFormatException ignored) {
    }
    try {
        JsDate js = JsDate.create(date);
        return new Date((long) js.getTime());
    } catch (JavaScriptException ignored) {
    }
    return null;
}

From source file:com.googlecode.gwt.charts.client.util.DateHelper.java

License:Apache License

/**
 * Converts a JsDate into a java Date.//from w w w .j  a v a 2  s  . com
 * 
 * @param jsDate a JsDate value
 * @return a Date value
 */
public static Date getDate(JsDate jsDate) {
    if (jsDate == null) {
        return null;
    }
    return new Date((long) jsDate.getTime());
}

From source file:com.polymerui.client.util.Utils.java

License:Apache License

public static String i18formatDate(JsDate da) {
    Date dt = new Date((long) da.getTime());
    return DateFormat.toS(dt, false);
}

From source file:com.risevision.ui.client.common.directory.DataControllerBase.java

License:Open Source License

protected Date getValueDate(JavaScriptObject jsDataTable, int columnIndex, int rowIndex) {
    JsDate jsDate = getValueDateNative(jsDataTable, columnIndex, rowIndex);
    if (jsDate != null) {
        return new Date((long) jsDate.getTime());
    } else {//from w w w  . j  a  va  2s . c o  m
        return null;
    }
}

From source file:gov.nist.spectrumbrowser.client.SensorInfoDisplay.java

License:Open Source License

long getSelectedDayBoundary(long time) {
    JsDate jsDate = JsDate.create(time * 1000);
    jsDate.setHours(0, 0, 0, 0);//from  w ww. j a v  a  2s  .  co  m
    return (long) jsDate.getTime() / 1000;
}

From source file:gwt.material.design.addins.client.datetimepicker.MaterialDateTimePicker.java

License:Apache License

protected void onChange(JsDate date) {
    this.time = new Date((long) date.getTime());
    this.fireValueChangeEvent();
}

From source file:gwt.material.design.client.ui.MaterialDatePicker.java

License:Apache License

public Date getPickerDate() {
    try {//from ww w .j  a  v a 2 s  .c o  m
        JsDate selectedDate = getDatePickerValue(pickatizedDateInput);
        return new Date((long) selectedDate.getTime());
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

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.
 *//*from   w w  w  .j  av  a 2  s  .  co  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());
        }
    }
}

From source file:org.gwt.dynamic.common.client.features.FeatureAResult.java

License:MIT License

public final Date getDate() {
    JsDate result = date();
    return result != null ? new Date((long) result.getTime()) : null;
}

From source file:org.gwt.dynamic.common.client.util.JsUtils.java

License:MIT License

/**
 * Returns arbitrary property from given JSO by specified name as {@link Date} value.
 * /*  w ww .java  2  s . c  o  m*/
 * @param jso
 *          JSO where from property should be given
 * @param name
 *          Addressed property name
 * @return {@link JavaScriptObject} value of specified property or null if specified property name is undefined.
 */
public static Date getPropertyDate(JavaScriptObject jso, String name) {
    JsDate d = getPropertyJsDate(jso, name);
    return d != null ? new Date((long) d.getTime()) : null;
}