寻道
探寻程序之道,软件之道,生存之道,生活之道及生命之道。
BlogJava
首页
新随笔
联系
聚合
管理
197 Posts :: 1 Stories :: 344 Comments :: 0 Trackbacks
公告
MAIL: junglesong@gmail.com
MSN: junglesong_5@hotmail.com
常用链接
我的随笔
我的文章
我的评论
我的参与
最新评论
留言簿
(2)
给我留言
查看公开留言
查看私人留言
随笔分类
(218)
Ajax(3)
DB&SQL(3)
HTML,CSS&JS(17)
Java API(6)
JavaScript(5)
Java基础(39)
JMS(3)
Maven2之旅(13)
My way(3)
Object Orient Programming(33)
SSH(6)
Swing(9)
VBA(1)
Web开发(15)
个人作品(13)
开源包使用(1)
算法数据结构(27)
线程Thread(3)
随想录(18)
随笔档案
(121)
2008年10月 (6)
2008年9月 (11)
2008年8月 (8)
2008年7月 (10)
2008年6月 (8)
2008年5月 (7)
2008年4月 (9)
2008年3月 (6)
2008年2月 (2)
2008年1月 (5)
2007年12月 (7)
2007年11月 (3)
2007年10月 (3)
2007年9月 (5)
2007年8月 (7)
2007年7月 (4)
2007年6月 (20)
个人软件下载
Sql Anywhere在华军的下载页面
SqlToolBox
文件批量命名器在华军的下载页面
目录文件比较器在华军的下载页面
我的其它博客
我的邻居们
BeanSoft's Java Blog
BlueDavy之技术Blog
CowNew开源团队
DANCE WITH JAVA
David.Turing's blog
fastpace
itkui的博客
Java快速开发平台
Java杂家
Jiangshachina
liaojiyong
Long的博客
Max On Java
mycsdnc#blog
Steady's Java Zone
sterning
zkjbeyond
信拈妙偶
千里冰封
和风细雨
寻道
山风小子的博客
庄周梦蝶
朱远翔 的博客
每日一得
点燃闪电
生活源于奋斗不息
翠湖月色
蛟龍居
谈笑有鸿儒,往来无白丁
铁手剑谱
鱼上游
最新随笔
1. 球拍式导航菜单效果的实现
2. SQL注入攻击及其防范浅谈
3. 四种CSS链接按钮示例
4. 寻章摘句
5. 使用CSS设置表格二
6. VBA系列讲义
7. 使用CSS设置表格
8. 工字型布局的两种形式及其制法
9. 使用无序列表制作导航菜单
10. CSS固定宽度两栏居中示例
搜索
积分与排名
积分 - 140575
排名 - 54
最新评论
1. re: JTable常见用法细则
非常好,很有用,谢谢啊!
--menghuan
2. re: SQL注入攻击及其防范浅谈
很不错的文章,看来我以后要多注意细节问题了!
--日月雨林@gmail.com
3. re: 二叉树搜索树代码
老兄,二叉树有没有实际应用的实例。
--sclsch
4. re: 使用CSS设置表格
评论内容较长,点击标题查看
--sitinspring
5. re: 使用CSS设置表格
评论内容较长,点击标题查看
--sclsch
阅读排行榜
1. Dom4j下载及使用Dom4j读写XML简介(3452)
2. 使用commons-fileupload实现单个和多个文件上传(2902)
3. 三种权限设计方案的归纳和比较(2623)
4. JTable常见用法细则(2534)
5. 使用CSS实现侧边Tab菜单栏(1983)
评论排行榜
1. SqlToolBox 1.60发布,介绍及使用(18)
2. 程序员之路探究(14)
3. 三种权限设计方案的归纳和比较(11)
4. 设计构建一个软件程序的基本步骤探讨(10)
5. 使用CSS实现侧边Tab菜单栏(8)
60天内阅读排行
1. 分页技术及其实现(1529)
2. 表单的设计浅谈(1268)
3. 数据库设计三范式应用实战(1252)
4. 使用无序列表制作导航菜单(1096)
5. 使用模板方法模式简化控制层类(Action)的设计(997)
动态生成日历
package
com.sitinspring.datetime;
import
java.util.ArrayList;
import
java.util.List;
public
class
MonthlyCalendar
{
private
static
final
String tab
=
"
\t
"
;
//
日历的年月
private
String yearMonth;
//
一个年月的日期
private
List
<
String
>
days;
public
MonthlyCalendar(String yearMonth)
{
this
.yearMonth
=
yearMonth;
fillDays();
}
private
void
fillDays()
{
days
=
new
ArrayList
<
String
>
();
//
每个月第一日前的空白
int
spacesBeforeFirstDay
=
DateTimeUtil.getWeekOfFirstDay(yearMonth);
for
(
int
i
=
0
;i
<
spacesBeforeFirstDay;i
++
)
{
days.add(tab);
}
//
每个月的日期
int
dayCountInaMonth
=
DateTimeUtil.getDaysInAMonth(yearMonth);
for
(
int
i
=
0
;i
<
dayCountInaMonth;i
++
)
{
days.add((i
+
1
)
+
tab);
}
}
public
String getText()
{
StringBuffer sb
=
new
StringBuffer();
sb.append(
"
===
"
+
yearMonth
+
"
===\r\n
"
);
sb.append(
"
--------------------------------------------------\r\n
"
);
for
(
int
i
=
0
;i
<
days.size();i
++
)
{
sb.append(days.get(i));
if
((i
+
1
)
%
7
==
0
)
{
sb.append(
"
\r\n
"
);
}
}
sb.append(
"
\r\n--------------------------------------------------\r\n
"
);
return
sb.toString();
}
public
static
void
main(String[] args)
{
System.out.println(
new
MonthlyCalendar(
"
2008.8
"
).getText());
}
}
package
com.sitinspring.datetime;
import
java.io.BufferedWriter;
import
java.io.FileWriter;
import
java.io.IOException;
public
class
CalendarMaker
{
public
CalendarMaker(
int
year)
{
this
(String.valueOf(year));
}
public
CalendarMaker(String year)
{
//
生成日历文件
makeFile(year);
}
private
void
makeFile(String fileName)
{
try
{
BufferedWriter out
=
new
BufferedWriter(
new
FileWriter(fileName
+
"
.txt
"
));
for
(
int
i
=
1
; i
<
13
; i
++
)
{
out.write(
new
MonthlyCalendar(fileName
+
"
.
"
+
i).getText());
//
将字符串“内容”写入文件
}
out.close();
}
catch
(IOException e)
{
e.printStackTrace();
}
}
public
static
void
main(String[] args)
{
new
CalendarMaker(
2008
);
}
}
package
com.sitinspring.datetime;
import
java.text.Format;
import
java.text.SimpleDateFormat;
import
java.util.Calendar;
import
java.util.Date;
import
java.util.GregorianCalendar;
/** */
/**
* 日期时间处理实用类
*
*
@author
sitinspring(junglesong@gmail.com)
*
@since
2008-7-18 上午10:30:15
* @vsersion 1.00 创建 sitinspring 2008-7-18 上午10:30:15
*/
public
final
class
DateTimeUtil
{
private
DateTimeUtil()
{
}
/** */
/**
* 以格式format返回表示日期时间的字符串
*
*
@param
format
*
@return
*/
public
static
String getDateTimeStr(String format)
{
Date date
=
new
Date();
Format formatter
=
new
SimpleDateFormat(format);
return
formatter.format(date);
}
/** */
/**
* 取得当前日期时间
*
*
@return
*/
public
static
String getCurrDateTime()
{
return
getDateTimeStr(
"
yyyy.MM.dd HH:mm:ss
"
);
}
/** */
/**
* 取得当前日期,不足两位前补零
*
*
@return
*/
public
static
String getCurrDate()
{
return
getDateTimeStr(
"
yyyy.MM.dd
"
);
}
/** */
/**
* 取得当前日期
*
*
@return
*/
public
static
String getSimpleCurrDate()
{
return
getDateTimeStr(
"
yyyy.M.d
"
);
}
/** */
/**
* 取得当前时间
*
*
@return
*/
public
static
String getCurrTime()
{
return
getDateTimeStr(
"
HH:mm:ss
"
);
}
/** */
/**
* 取得当前年月
*
*
@return
*/
public
static
String getCurrYearMonth()
{
return
getDateTimeStr(
"
yyyy.MM
"
);
}
/** */
/**
* 从文本形式日期取得Date日期时间
*
*
@param
strMonth
*
@return
*/
private
static
Date getDate(String strMonth)
{
SimpleDateFormat myFormatter
=
new
SimpleDateFormat(
"
yyyy.MM.dd
"
);
try
{
java.util.Date date
=
myFormatter.parse(strMonth);
return
date;
}
catch
(Exception ex)
{
return
null
;
}
}
/** */
/**
* 得到两个文本日期之间的天数
*
*
@param
startDate
*
@param
endDate
*
@return
*/
public
static
long
getDaysBetween(String startDate, String endDate)
{
Date dStart
=
getDate(startDate);
Date dEnd
=
getDate(endDate);
return
(dEnd.getTime()
-
dStart.getTime())
/
(
24
*
60
*
60
*
1000
);
}
/** */
/**
* 取某月的天数,strMonth的格式是"yyyy.MM"
*
@param
strMonth
*
@return
*/
public
static
int
getDaysInAMonth(String strMonth)
{
String[] arr
=
strMonth.split(
"
[.]
"
);
//
Create a calendar object of the desired month
Calendar cal
=
new
GregorianCalendar(Integer.parseInt(arr[
0
]), Integer
.parseInt(arr[
1
])
-
1
,
1
);
//
Get the number of days in that month
int
days
=
cal.getActualMaximum(Calendar.DAY_OF_MONTH);
return
days;
}
/** */
/**
* 取某月第一天是周几,strMonth的格式是"yyyy.MM"
*
@param
strMonth
*
@return
*/
public
static
int
getWeekOfFirstDay(String strMonth)
{
String[] arr
=
strMonth.split(
"
[.]
"
);
Calendar xmas
=
new
GregorianCalendar(Integer.parseInt(arr[
0
]), Integer
.parseInt(arr[
1
])
-
1
,
1
);
int
dayOfWeek
=
xmas.get(Calendar.DAY_OF_WEEK)
-
1
;
return
dayOfWeek;
}
public
static
void
main(String[] args)
{
System.out.println(
"
当前日期时间为:
"
+
getCurrDateTime());
System.out.println(
"
当前日期为:
"
+
getCurrDate());
System.out.println(
"
当前日期为:
"
+
getSimpleCurrDate());
System.out.println(
"
当前时间为:
"
+
getCurrTime());
System.out.println(
"
2008.07.05与2008.07.18之间相隔: