数据库中查询出来的时间是:2015-09-24 14:30:26.2,带有毫秒,需要去掉。

方法一:

public static Timestamp getSystemTime()

{
Date dt = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = df.format(dt);
java.sql.Timestamp buydate = java.sql.Timestamp.valueOf(nowTime);

return buydate;
}

 
方法二:
 
-------------如果Web客户端需要使用,建议使用JSTL----------------

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"% >

<fmt:formatDate value="${}" pattern="yyyy-MM-dd HH:mm:ss" />

读取数据库中timestamp类型去掉毫秒的更多相关文章

  1. 数据库中字段类型对应的C#中的数据类型

    数据库中字段类型对应C#中的数据类型: 数据库                 C#程序 int int32 text string bigint int64 binary System.Byte[] ...

  2. 数据库中字段类型对应的C#中的数据类型(转载)

    数据库中字段类型对应C#中的数据类型: 数据库                 C#程序 int int32 text string bigint int64 binary System.Byte[] ...

  3. 编写SqlHelper使用,在将ExecuteReader方法封装进而读取数据库中的数据时会产生Additional information: 阅读器关闭时尝试调用 Read 无效问题,解决方法与解释

    在自学杨中科老师的视频教学时,拓展编写SqlHelper使用,在将ExecuteReader方法封装进而读取数据库中的数据时 会产生Additional information: 阅读器关闭时尝试调用 ...

  4. 【网络收集】数据库中字段类型对应C#中的数据类型

    数据库中字段类型对应C#中的数据类型: 数据库 C#程序 int int32 text string bigint int64 binary System.Byte[] bit Boolean cha ...

  5. 数据库中字段类型对应C#中的数据类型

    数据库中字段类型对应C#中的数据类型:数据库 C#程序 int int32 text string bigint int64 binary System.Byte[] bit Boolean char ...

  6. 点滴积累【C#】---C#实现上传word以流形式保存到数据库和读取数据库中的word文件。

    本文修改来源:http://www.cnblogs.com/zmgdpg/archive/2005/03/31/129758.html 效果: 数据库: 思路: 首先保存word到数据库:获取上传文件 ...

  7. MYSQL中TIMESTAMP类型的默认值理解

    MYSQL中TIMESTAMP类型可以设定默认值,就像其他类型一样. 1.自动UPDATE 和INSERT 到当前的时间:表:----------- Table   Create Table      ...

  8. java和数据库中日期类型的常见用法

    (1)java中日期类型:Date.Timestamp(2)数据库中:Date.Timestamp(3)字符串和Date之间的格式化转换:    SimpleDateFormat类方法: format ...

  9. SQL数据库中字段类型 与C#中的对应字段类型

    数据库中的字段类型和对应的C#中的对应字段类型 数据库                 C#程序int int32text stringbigint int64binary System.Byte[] ...

随机推荐

  1. [AngularJS] AngularJS 1.3 $scope.$watchGroup

    $watchGroup can monitor an array or expression. We watch both email and password by using the same c ...

  2. python中字符串list转化为数值型

    之前在网上找相关的资料,给出的方法都不合适, 经过很长时间的试错才知道源于python2.X和python3.X的不同, 原理都是采用map函数,但是二者返回的信息不同 Python2.x,可以使用m ...

  3. 浅谈PHP数据结构之栈

    今天開始进阶自己的PHP,首先一切的编程语言都须要修炼自己的"内功",何为程序猿的"内功",我想大概就是数据结构和算法了吧 .毕竟是灵魂,是普通程序猿到高级程序 ...

  4. Java之逆向工程(1) - 反编译、修补和逆向工程技术 读书笔记

    透视JAVA——反编译.修补和逆向工程技术 读书笔记 1.  Java source is not compiled to binary machine code like C/C++ source ...

  5. 用sqldevelop进行连接linux中ret Hat 6.2 中的oracle步骤

    1.下载Oracle Instant Client (32-bit) 因为PL/SQL只支持32位的Oracle,所以必须下载对应的32位的才可以. 只需要下载instantclient-basic- ...

  6. PHP-静态方法(static)继承等分析

    <?php class A { const CONST_NAME = 'A'; public static $static_name = 'A'; public static $static_n ...

  7. Python 常见错误及解决办法

    错误: Traceback (most recent call last): File "I:/Papers/consumer/codeandpaper/RegressionandGBDTa ...

  8. IntelliJ IDEA类头注释和方法注释

    The template is editable. Along with static text, code and comments, you can also use predefined var ...

  9. appium 1.6.3 + ios 10.2 + xcode 8.2.1 真机运行safari

    启动appium 命令: appium --address "127.0.0.1" --session-override --pre-launch --debug-log-spac ...

  10. Informix 語法

    1.修改表名稱 RENAME TABLE old_table_name TO new_table_name; 2.分頁 select  SKIP 0 FIRST 1 * from tablename ...