/** 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()); }
/** * 現在時刻を返す。もし、現在時刻が陽に設定されていれば、その時刻を返す。 そうでなければ、OS から現在時刻を取得して返す。 * * @return */ public static DateTime getCurrentDateTime() { if (currentDateTime != null) return new DateTime(currentDateTime.getTime()); else return new DateTime(System.currentTimeMillis()); }
/** * 現在時刻をミリ秒単位で返す。現在時刻が陽に設定されていれば、その現在時刻を返す。 そうでなければ、new Date().getTime() と同じ。 * * @return */ public static long getCurrentTime() { if (currentDateTime != null) return currentDateTime.getTime(); else return new Date().getTime(); }
public static String getTimeString(DateTime date) { return getTimeString(date.getTime()); }