package com.kk.test03;
import java.text.SimpleDateFormat;
import java.util.*;
public class p1 {
public static void main(String[] args) {
//long l = System.currentTimeMillis();
Date nowTime = new Date(System.currentTimeMillis());
System.out.println(System.currentTimeMillis());
SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd");
String retStrFormatNowDate = sdFormatter.format(nowTime);
// 使用默认时区和语言环境获得一个日历
Calendar cal = Calendar.getInstance();
// 赋值时年月日时分秒常用的6个值,注意月份下标从0开始,所以取月份要+1
System.out.println("年:" + cal.get(Calendar.YEAR));
System.out.println("月:" + (cal.get(Calendar.MONTH) + 1));
System.out.println("日:" + cal.get(Calendar.DAY_OF_MONTH));
System.out.println("时:" + cal.get(Calendar.HOUR_OF_DAY));
System.out.println("分:" + cal.get(Calendar.MINUTE));
System.out.println("秒:" + cal.get(Calendar.SECOND));
System.out.println(retStrFormatNowDate);
Vector v = new Vector();
Student[] stus = new Student[3];
stus[0] = new Student("李雷", 10, 98);
stus[1] = new Student("韩梅梅", 11, 95);
stus[2] = new Student("Poly", 12, 100);
for (Student stu : stus) {
v.addElement(stu);
}
for(int i = 0; i < v.size(); i++) {
Student s = (Student) v.elementAt(i);
System.out.println(" 输出:"+s.getId());
}
}
}
class Student {
private String name;
private int id;
private float score;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public float getScore() {
return score;
}
public void setScore(float score) {
this.score = score;
}
/**
* @param name
* @param id
* @param score
*/
public Student(String name, int id, float score) {
this.name = name;
this.id = id;
this.score = score;
}
}