java格式化日期时间的函数
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
System.out.println(sdf.format(date));
SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
System.out.println(sdf2.format(date));
Calendar c = Calendar.getInstance();
System.out.println(c.get(Calendar.MONTH)+1);
Date d=new Date(2010,5,12,13,24,30);
c.setTime(d);
System.out.println(c.get(Calendar.MONTH)+1);
--------------------------------------------------------------------
test=new JdbcTest();
String sql="{call proc_select3(?)};"; //调用语句
try {
CallableStatement proc=test.getConnection().prepareCall(sql);
proc.setString(1, "男");
//proc.execute();
ResultSet rs= proc.executeQuery();
while(rs.next())
{
System.out.print("id: "+rs.getInt("id"));
System.out.print(" userName :"+rs.getString("username"));
System.out.print(" age :"+rs.getInt("age"));
System.out.println(" sex :"+rs.getString("sex"));
Timestamp time=rs.getTimestamp("birthday");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(">>>>>>>>>>>>>>>>>>"+sdf.format(time));
System.out.println(" birthday :"+rs.getDate("birthday"));
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
相关文档:
1. HttpSession session = request.getSession()
与HttpSession session = request.getSession(true)的区别?
参考答案:
getSession(true)的函数原型为::HttpSession session = request.getSession (Boolean create)
如果有与当前的request先关联的HttpSession,那么返回request相关联的HttpS ......
import java.util.*;
import java.util.regex.Pattern;
public class StrTools {
/**
* 分割字符串
*
* @param str String 原始字符串
* @param splitsign String 分隔符
* @return String[] 分割后的字符串数组
*/
@SuppressWarnings("unchecked")
public static String[] split(Stri ......
字符串
1、获取字符串的长度
length()
2 、判断字符串的前缀或后缀与已知字符串是否相同
前缀 startsWith(String s)
后缀 endsWith(String s)
3、比较两个字符串
equals(String s)
4、把字符串转化为相应的数值
int型 Integer.parseInt(字符串)
......
/*
Function name: myGetHttpFile2
Description: 爬网页用
Input: URL 例如:http://www.126.com
Output: 字符串,网页的HTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
......
ArrayList是最常用的List实现类,内部是通过数组实现的,它允许对元素进行快速随机访问。数组的缺点是每个元素之间不能含有“空隙”,当数组大小不满足时需要增加存储能力,就要将已有数组数据复制到新的存储空间中。当从ArrayList的中间位置插入或者删除元素时,需要对数组进行复制、移动,代价比较高。因此, ......