次の例は、SimpleDateFormat クラスの format(date) メソッドを使用して時刻をフォーマットする方法を示しています
1 2 3 4 5 6 7 8 9 10 |
import java.text.SimpleDateFormat;import java.util. Date ; public class Main{
public static void main(String[] args){
Date date = new Date ();
String strDateFormat = "yyyy-MM-dd HH:mm:ss" ;
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
System.out.println(sdf.format( date ));
}}
|
ログイン後にコピー
上記のコードを実行した出力結果は次のとおりです:
上記は Java の例の内容です - 時刻のフォーマット(SimpleDateFormat)、その他の関連コンテンツについては、PHP 中国語 Web サイト (www.php.cn) にご注意ください。