Пример #1
0
  /** Waits for a while. */
  public static void waitForTick() {
    if (currentDateTime != null) {
      setCurrentTime(currentDateTime.getTime() + 20);
      return;
    }

    long now = new Date().getTime();
    do {
      try {
        Thread.sleep(1);
      } catch (InterruptedException e) {
        // ignore.
      }
    } while (now == TimeUtil.getCurrentTime());
  }
Пример #2
0
 /**
  * 現在時刻を返す。もし、現在時刻が陽に設定されていれば、その時刻を返す。 そうでなければ、OS から現在時刻を取得して返す。
  *
  * @return
  */
 public static DateTime getCurrentDateTime() {
   if (currentDateTime != null) return new DateTime(currentDateTime.getTime());
   else return new DateTime(System.currentTimeMillis());
 }
Пример #3
0
 /**
  * 現在時刻をミリ秒単位で返す。現在時刻が陽に設定されていれば、その現在時刻を返す。 そうでなければ、new Date().getTime() と同じ。
  *
  * @return
  */
 public static long getCurrentTime() {
   if (currentDateTime != null) return currentDateTime.getTime();
   else return new Date().getTime();
 }
Пример #4
0
 public static String getTimeString(DateTime date) {
   return getTimeString(date.getTime());
 }