import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
public class TestDate {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs?user=root&password=root");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select pdate from article");
while(rs.next()){
//System.out.println(rs.getDate("pdate"));
Date d = rs.getDate("pdate");
SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
System.out.println(sFormat.format(d));
}
rs.close();
stat.close();
conn.close();
}
}
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
public class TestDate {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs?user=root&password=root");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select pdate from article");
while(rs.next()){
//System.out.println(rs.getDate("pdate"));
Date d = rs.getDate("pdate");
SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
System.out.println(sFormat.format(d));
}
rs.close();
stat.close();
conn.close();
}
}