锘??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 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 大荔县| 曲沃县| 阿克苏市| 南平市| 遵义市| 丰县| 鸡泽县| 蒙阴县| 宝丰县| 临高县| 永兴县| 乐清市| 聂荣县| 黑水县| 越西县| 修武县| 平远县| 诏安县| 庆城县| 石阡县| 安达市| 津南区| 茌平县| 朝阳区| 三门县| 惠水县| 太谷县| 靖西县| 临西县| 宁安市| 德昌县| 华阴市| 肃北| 久治县| 旅游| 彭水| 乌兰察布市| 巴南区| 平乐县| 德清县| 休宁县|