Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / util / Date.js
1 Clazz.load (null, "java.util.Date", null, function () {
2 java.util.Date = Date;
3 Clazz.decorateAsType (java.util.Date, "java.util.Date", null, [java.io.Serializable, Cloneable, Comparable]);
4
5 Clazz.defineMethod (java.util.Date, "clone", 
6 function () {
7 return new Date (this.getTime ());
8 });
9
10 Clazz.defineMethod (java.util.Date, "before", 
11 function (when) {
12 return this.getTime () < when.getTime ();
13 }, "java.util.Date");
14 Clazz.defineMethod (java.util.Date, "after", 
15 function (when) {
16 return this.getTime () > when.getTime ();
17 }, "java.util.Date");
18 Clazz.defineMethod (java.util.Date, "equals", 
19 function (obj) {
20 return Clazz.instanceOf (obj, java.util.Date) && this.getTime () == (obj).getTime ();
21 }, "Object");
22 Clazz.defineMethod (java.util.Date, "compareTo", 
23 function (anotherDate) {
24 var thisTime = this.getTime ();
25 var anotherTime = anotherDate.getTime ();
26 return (thisTime < anotherTime ? -1 : (thisTime == anotherTime ? 0 : 1));
27 }, "java.util.Date");
28 Clazz.defineMethod (java.util.Date, "compareTo", 
29 function (o) {
30 return this.compareTo (o);
31 }, "Object");
32 Clazz.defineMethod (java.util.Date, "hashCode", 
33 function () {
34 var ht = this.getTime ();
35 return parseInt (ht) ^ parseInt ((ht >> 32));
36 });
37 });