Java时间转换字符
以下是日期时间的转换字符。
以下是一个示例。
示例
import java.util.Calendar; public class Demo { public static void main( String args[] ) { Calendar cal = Calendar.getInstance(); //日期 System.out.printf("Date....\n"); System.out.printf( "%1$tA, %1$tB %1$td, %1$tY\n", cal ); System.out.printf( "%1$ta, %1$tb %1$te, %1$ty\n", cal ); //时间 System.out.printf("\nTime....\n"); System.out.printf( "%1$tH:%1$tM:%1$tS\n", cal ); System.out.printf( "%1$tZ %1$tI:%1$tM:%1$tS", cal ); } }
输出结果
Date.... Monday, November 26, 2018 Mon, Nov 26, 18 Time.... 12:41:28 UTC 12:41:28