home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 1.1 KB | 44 lines |
- import java.util.*;
-
- // GMTTime $B8=:_$N(BGMT$B;~9o$^$?$O%m!<%+%k;~9o$rJV$94X?t(B
- // $B;~9o$O!"D9$5(B3$B$N(Bint$B$NG[Ns$G!"@hF,$NMWAG$+$i=g$K;~(B,$BJ,(B,$BIC$,(B
- // $BF~$C$F$$$k(B
- // Functions:
- // GMTTime() constructor
- // getTime(int h) h $B;~4V?J$s$@(B(h < 0 $B$J$iCY$l$?(B)$BCO0h$N;~9o$rJV$9(B
- // getHour(int h) h $B;~4V?J$s$@(B(h < 0 $B$J$iCY$l$?(B)$BCO0h$N(B"$B;~(B"$B$rJV$9(B
- //
-
- class GMTTime extends Object {
- int gmttime[];
-
- public GMTTime() {
- gmttime = new int[3];
- String GMTdate = new Date().toGMTString();
- int pos = GMTdate.indexOf(":"); // search time separator
- gmttime[0] = Integer.parseInt(GMTdate.substring(pos-2,pos)); // hour
- gmttime[1] = Integer.parseInt(GMTdate.substring(pos+1,pos+3)); // min
- gmttime[2] = Integer.parseInt(GMTdate.substring(pos+4,pos+6)); // sec
- }
-
- public int[] getTime(int h) {
- int localtime[] = new int[3];
- localtime[0] = gmttime[0] + h;
- if (localtime[0] > 24) {
- localtime[0] -= 24;
- }
- localtime[1] = gmttime[1];
- localtime[2] = gmttime[2];
- return localtime;
- }
-
- public int getHour(int h) {
- int hour = gmttime[0] + h;
- if (hour > 24) {
- hour -= 24;
- }
- return hour;
- }
- }
-
-