com.google.gwt.ajaxloader.client
Class JsDate

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by com.google.gwt.ajaxloader.client.JsDate

public class JsDate
extends com.google.gwt.core.client.JavaScriptObject

Wraps a JavaScript Date object.


Constructor Summary
protected JsDate()
           
 
Method Summary
static JsDate create()
          Create a JsDate with the current time.
static JsDate create(double time)
          Create a date given the time in milliseconds.
 long getTime()
          A wrapper for the JavaScript Date's getTime() method.
static boolean isDate(com.google.gwt.core.client.JavaScriptObject js)
          Tests if the JavaScriptObject can be cast to JsDate.
static java.util.Date toJava(JsDate js)
          Converts a JsDate to a Java Date.
static JsDate toJs(java.util.Date java)
          Converts a Java Date to a JsDate.
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsDate

protected JsDate()
Method Detail

create

public static JsDate create()
Create a JsDate with the current time.

Returns:
A JsDate with the current time.

create

public static JsDate create(double time)
Create a date given the time in milliseconds.

Parameters:
time - A time value in milliseconds. Uses the double type for efficiency.
Returns:
A JsDate with the given time.

isDate

public static boolean isDate(com.google.gwt.core.client.JavaScriptObject js)
Tests if the JavaScriptObject can be cast to JsDate. Checks if the underlying JavaScript object has a method called getTime() that returns a number.

Parameters:
js - A JavaScriptObject that may or may not be wrapping a JavaScript Date object.
Returns:
false if the JavaScriptObject is null or if it cannot be cast to JsDate, otherwise true.

toJava

public static java.util.Date toJava(JsDate js)
Converts a JsDate to a Java Date. If the JsDate is null, the function returns null.

Parameters:
js - A JsDate.
Returns:
A Java Date object, or null, if js is null.

toJs

public static JsDate toJs(java.util.Date java)
Converts a Java Date to a JsDate. If the Date is null, the function returns null.

Parameters:
java - A Java Date.
Returns:
An analogous JsDate, or null if the original Java Date was null.

getTime

public final long getTime()
A wrapper for the JavaScript Date's getTime() method.

Returns:
The time in milliseconds corresponding to this JsDate.