两个JSP+ORACLE的问题(高手请进!) 用sql查询时将时间日期转换成去掉时间的不就可以了吗. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package com.hoten.util;import java.util.*;/** * <p>Title: Time </p> * <p>Description: </p> * 此类主要用来取得本地系统的系统时间并用下面5种格式显示 * 1. YYMMDDHH 8位 * 2. YYMMDDHHmm 10位 * 3. YYMMDDHHmmss 12位 * 4. YYYYMMDDHHmmss 14位 * 5. YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒) * <p>Copyright: Copyright (c) 2003</p> * <p>Company: hoten </p> * @author lqf * @version 1.0 */public class Time { public static final int YYMMDDhhmmssxxx=15; public static final int YYYYMMDDhhmmss=14; public static final int YYMMDDhhmmss=12; public static final int YYMMDDhhmm=10; public static final int YYMMDDhh=8;/** * 取得本地系统的时间,时间格式由参数决定 * @param format 时间格式由常量决定 * @return String 具有format格式的字符串 */ public static String getTime(int format){ StringBuffer cTime=new StringBuffer(15); Calendar time=Calendar.getInstance(); int miltime=time.get(Calendar.MILLISECOND); int second=time.get(Calendar.SECOND); int minute=time.get(Calendar.MINUTE); int hour=time.get(Calendar.HOUR_OF_DAY); int day =time.get(Calendar.DAY_OF_MONTH); int month=time.get(Calendar.MONTH)+1; int year =time.get(Calendar.YEAR); time=null; if(format!=14){ if(year>=2000) year=year-2000; else year=year-1900; } if(format>=2){ if(format==14) cTime.append(year); else cTime.append(getFormatTime(year,2)); } if(format>=4) cTime.append(getFormatTime(month,2)); if(format>=6) cTime.append(getFormatTime(day,2)); if(format>=8) cTime.append(getFormatTime(hour,2)); if(format>=10) cTime.append(getFormatTime(minute,2)); if(format>=12) cTime.append(getFormatTime(second,2)); if(format>=15) cTime.append(getFormatTime(miltime,3)); return cTime.toString().trim(); }/** * 产生任意位的字符串 * @param time 要转换格式的时间 * @param format 转换的格式 * @return String 转换的时间 */ private static String getFormatTime(int time,int format){ StringBuffer numm=new StringBuffer(format); int length=String.valueOf(time).length(); if(format<length) return null; for(int i=0 ;i<format-length ;i++){ numm.append("0"); } numm.append(time); return numm.toString().trim(); }} long getTime(Date) 返回1970-1-1以来的毫秒数,Date(long)反之。在数据库中,result.getTimestamp("colname"). servlet生成进度条图片的问题 HttpClient请求dwr失败 validate验证 如何发布一个包含applet的页面 如何在tomcat下发布客户端的activeX控件(送100分) 关于tomcat问题 请问如何在浏览器端用base64对用户密码进行加密后,再传输给服务器 请问学习jsp需要知道哪些知识??? 请问哪里可以下载MYSQL? jsp运行时的错误提示! 简单的问题 这是一个什么问题?
import java.util.*;
/**
* <p>Title: Time </p>
* <p>Description: </p>
* 此类主要用来取得本地系统的系统时间并用下面5种格式显示
* 1. YYMMDDHH 8位
* 2. YYMMDDHHmm 10位
* 3. YYMMDDHHmmss 12位
* 4. YYYYMMDDHHmmss 14位
* 5. YYMMDDHHmmssxxx 15位 (最后的xxx 是毫秒)
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: hoten </p>
* @author lqf
* @version 1.0
*/
public class Time {
public static final int YYMMDDhhmmssxxx=15;
public static final int YYYYMMDDhhmmss=14;
public static final int YYMMDDhhmmss=12;
public static final int YYMMDDhhmm=10;
public static final int YYMMDDhh=8;
/**
* 取得本地系统的时间,时间格式由参数决定
* @param format 时间格式由常量决定
* @return String 具有format格式的字符串
*/
public static String getTime(int format){
StringBuffer cTime=new StringBuffer(15);
Calendar time=Calendar.getInstance();
int miltime=time.get(Calendar.MILLISECOND);
int second=time.get(Calendar.SECOND);
int minute=time.get(Calendar.MINUTE);
int hour=time.get(Calendar.HOUR_OF_DAY);
int day =time.get(Calendar.DAY_OF_MONTH);
int month=time.get(Calendar.MONTH)+1;
int year =time.get(Calendar.YEAR);
time=null;
if(format!=14){
if(year>=2000) year=year-2000;
else year=year-1900;
}
if(format>=2){
if(format==14) cTime.append(year);
else cTime.append(getFormatTime(year,2));
}
if(format>=4)
cTime.append(getFormatTime(month,2));
if(format>=6)
cTime.append(getFormatTime(day,2));
if(format>=8)
cTime.append(getFormatTime(hour,2));
if(format>=10)
cTime.append(getFormatTime(minute,2));
if(format>=12)
cTime.append(getFormatTime(second,2));
if(format>=15)
cTime.append(getFormatTime(miltime,3));
return cTime.toString().trim();
}
/**
* 产生任意位的字符串
* @param time 要转换格式的时间
* @param format 转换的格式
* @return String 转换的时间
*/
private static String getFormatTime(int time,int format){
StringBuffer numm=new StringBuffer(format);
int length=String.valueOf(time).length(); if(format<length) return null; for(int i=0 ;i<format-length ;i++){
numm.append("0");
}
numm.append(time);
return numm.toString().trim();
}
}
在数据库中,result.getTimestamp("colname").