锘??xml version="1.0" encoding="utf-8" standalone="yes"?>这里只有精品久久,国语自产在线不卡,性视频一区二区三区http://www.aygfsteel.com/billzhang88169/archive/2007/12/31/171633.html#171812鍑屾櫒椋?/dc:creator>鍑屾櫒椋?/author>Mon, 31 Dec 2007 02:21:00 GMThttp://www.aygfsteel.com/billzhang88169/archive/2007/12/31/171633.html#171812package JDBC;

import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
*
* @author oakertree
*
*/
public class TestJDBCDate {
public static void main(String[] args) {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// new com.mysql.jdbc.Driver();
con = DriverManager.getConnection("jdbc:mysql://localhost:3307/test", "root", "admini");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM time");
while(rs.next()) {
/*
Date d = rs.getDate("date");
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy騫碝M鏈坉d鏃?quot;);
System.out.println(sdf.format(d));
*/

/*
Time t = rs.getTime("time");
SimpleDateFormat sdf = new SimpleDateFormat("HH鏃秏m鍒唖s縐?quot;);
System.out.println(sdf.format(t));
*/

Date d = rs.getDate("datetime");
Time t = rs.getTime("datetime");
SimpleDateFormat sdfdate = new SimpleDateFormat("yyyy騫碝M鏈坉d鏃?quot;);
SimpleDateFormat sdftime = new SimpleDateFormat("HH鏃秏m鍒唖s縐?quot;);
System.out.println(sdfdate.format(d) + sdftime.format(t));

/*
Timestamp dt = rs.getTimestamp("datetime");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy騫碝M鏈坉d鏃H鏃秏m鍒唖s縐?quot;);
System.out.println(sdf.format(dt));
*/

//寰楀埌鏃ユ湡涓殑鏈?
/*
Calendar c = Calendar.getInstance();
c.setTime(d);
System.out.println(c.get(Calendar.MONTH));
*/
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
/*
+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| date | date | YES | | NULL | |
| time | time | YES | | NULL | |
| datetime | datetime | YES | | NULL | |
+----------+----------+------+-----+---------+-------+
*/


]]>
re: JAVA 榪炴帴MYSQLhttp://www.aygfsteel.com/billzhang88169/archive/2007/12/30/171633.html#171742姊佹枃鏀?/dc:creator>姊佹枃鏀?/author>Sun, 30 Dec 2007 10:56:00 GMThttp://www.aygfsteel.com/billzhang88169/archive/2007/12/30/171633.html#171742

]]>
re: JAVA 榪炴帴MYSQL[鏈櫥褰昡http://www.aygfsteel.com/billzhang88169/archive/2007/12/29/171633.html#171637xmlspyxmlspySat, 29 Dec 2007 14:58:00 GMThttp://www.aygfsteel.com/billzhang88169/archive/2007/12/29/171633.html#171637

xmlspy 2007-12-29 22:58 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 盐池县| 泗水县| 财经| 平乐县| 麻阳| 三门峡市| 应用必备| 吴江市| 平潭县| 上饶市| 遵义市| 东丽区| 和林格尔县| 喀什市| 库尔勒市| 兰考县| 蓬溪县| 福海县| 西乡县| 伊宁市| 万源市| 上蔡县| 宁波市| 新民市| 芷江| 鹿邑县| 保定市| 六枝特区| 桐柏县| 霍城县| 内黄县| 巴楚县| 灌南县| 普安县| 苏尼特右旗| 铜梁县| 禄丰县| 澎湖县| 枣强县| 沽源县| 临江市|