当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 有以下结构的数据源: date serviceid usercount factusercount canceluser newuser ------ ------------- ----------- ------------- -------- ----- 2003-9 505 13 2 0 0 2003-9 506 4 2 0 0 2003-9 509 14 5 0 ......
    摘要: 如何区分主键、外键;他们各自的作用是什么? ......


数据转换问题

我想在JSP中将String转换为Date,String转换为int,String转换为long  
  应该怎么做import那几个包

NO.1   作者: aku0708

java.io.*

NO.2   作者: Yssss1980

import   java.util.Date

NO.3   作者: yaray

String   strDate="2003-9-17"  
  java.util.Date   date   =   new   java.util.Date(strDate);  
   
  int   iStr   =   Integer.parseInt("1000");  
   
  String   str   =   "1000L";   //   大写的L  
  String   str   =   "1000l";   //   小写的L  
  String   str   =   "1000";  
  long   lStr   =   Long.parseLong(str);

NO.4   作者: junyi2003

String   strDate="2003-9-17"  
  java.util.Date   date   =   new   java.util.Date(strDate);  
   
  这个肯定不行的。我以前也是这么想当然的,结果被JVM否定了。  
 

NO.5   作者: junyi2003

如果取自SQL的话,可以用  
  Date   today=new   Date(rs.getTimestamp().getTime());

NO.6   作者: junyi2003

Class   Timestamp       //也许能满足你String转换   Date  
   
  public   static   Timestamp   valueOf(String   s)Converts   a   String   object   in   JDBC   timestamp   escape   format   to   a   Timestamp   value.  
  Parameters:  
  s   -   timestamp   in   format   yyyy-mm-dd   hh:mm:ss.fffffffff  
  Returns:  
  corresponding   Timestamp   value  
  Throws:  
  IllegalArgumentException   -   if   the   given   argument   does   not   have   the   format   yyyy-mm-dd   hh:mm:ss.fffffffff  
 


    摘要: 我想要把查询的结果通过datagrid输出!!! 请把答案发到我得邮箱sjinli2003@yahoo.com.cn 不胜感激!!! ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE