Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
System.out.println(sdf.format(date));
SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
System.out.println(sdf2.format(date));
Calendar c = Calendar.getInstance();
System.out.println(c.get(Calendar.MONTH)+1);
Date d=new Date(2010,5,12,13,24,30);
c.setTime(d);
System.out.println(c.get(Calendar.MONTH)+1);
--------------------------------------------------------------------
test=new JdbcTest();
String sql="{call proc_select3(?)};"; //调用语句
try {
CallableStatement proc=test.getConnection().prepareCall(sql);
proc.setString(1, "男");
//proc.execute();
ResultSet rs= proc.executeQuery();
while(rs.next())
{
System.out.print("id: "+rs.getInt("id"));
System.out.print(" userName :"+rs.getString("username"));
System.out.print(" age :"+rs.getInt("age"));
System.out.println(" sex :"+rs.getString("sex"));
Timestamp time=rs.getTimestamp("birthday");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(">>>>>>>>>>>>>>>>>>"+sdf.format(time));
System.out.println(" birthday :"+rs.getDate("birthday"));
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}