Initial commit
This commit is contained in:
16
Example_src/Chapter1-10/src/ch06/SimpleDateExample.java
Normal file
16
Example_src/Chapter1-10/src/ch06/SimpleDateExample.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package ch06;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class SimpleDateExample {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //A
|
||||
Date dt = sdf.parse("2009-8-30"); //B
|
||||
System.out.println("英文格式:" + dt);
|
||||
System.out.println();
|
||||
sdf.applyPattern("yyyy年MM月dd日"); //C
|
||||
String str = sdf.format(dt); //D
|
||||
System.out.println("中文格式:" + str);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user