001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.fukurou.util;
017
018 import java.util.Date ;
019
020 /**
021 * StopTimer は、指定ã?ä¸?®š時間ã?間ã?実行を停止しますã?
022 * 引数に、停止時間を秒単位でæŒ?®šしますã?
023 * 初期値はã€?¼?ç§?ですã?
024 *
025 * Usage: java org.opengion.fukurou.fukurou.util.StopTimer 停止時間(ç§? [-T]
026 *
027 * @og.group ユーãƒ?‚£リãƒ?‚£
028 *
029 * @version 4.0
030 * @author Kazuhiko Hasegawa
031 * @since JDK5.0,
032 */
033 public final class StopTimer {
034
035 /**
036 * すべてã�?staticメソãƒ?ƒ‰なので、コンストラクタを呼び出さなくしておきますã?
037 *
038 */
039 private StopTimer() {}
040
041 /**
042 * 処ç�?‚’実行すã‚?main メソãƒ?ƒ‰ですã?
043 *
044 * 引数には、å?ç�?‚’停止する 秒数 をå?力しますã?
045 * -T をå?力したå?合ã?、å?ç�?–‹始時刻を表示しますã?
046 *
047 * Usage: java org.opengion.fukurou.fukurou.util.StopTimer 停止時間(ç§? [-T]
048 *
049 * @param args コマンド引数配å?
050 */
051 public static void main( final String[] args ) {
052 long stopTime ;
053
054 if( args.length >= 1 ) { stopTime = 1000L * Long.parseLong( args[0] ) ; }
055 else {
056 LogWriter.log("Usage: java org.opengion.fukurou.fukurou.util.StopTimer 停止時間(ç§? [-T]");
057 return;
058 }
059
060 if( args.length ==2 && "-T".equals( args[1] ) ) {
061 System.out.println( new Date() );
062 }
063
064 try {
065 Thread.sleep( stopTime );
066 }
067 catch( InterruptedException ex ) {
068 LogWriter.log( "InterruptedException:" + ex.getMessage() );
069 }
070 }
071 }