首页 > 代码库 > Date类

Date类

 1 import java.text.SimpleDateFormat;
 2 import java.util.Date;
 3 import javax.swing.JOptionPane;
 4 
 5 public class Ch2Sample1 {
 6     
 7     public static void main(String[] args) {
 8         Date today = new Date();
 9         JOptionPane.showMessageDialog(null, today.toString());
10     
11         //日期格式
12         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");
13         JOptionPane.showMessageDialog(null, sdf.format(today));
14         
15         SimpleDateFormat sdf1 = new SimpleDateFormat("EEEE MMMM dd, yyyy");
16         JOptionPane.showMessageDialog(null, sdf1.format(today));
17     }
18 }