gcw633
自己寫的日期處理類--月份的第一天和最后一天
import
java.util.Calendar;
import
java.util.Date;
import
java.util.GregorianCalendar;
public
class
DoDate
{
//
當前月份的第一天
public
static
String firstDay()
{
java.text.SimpleDateFormat df
=
new
java.text.SimpleDateFormat(
"
yyyy-MM-dd
"
);
GregorianCalendar gc
=
(GregorianCalendar) Calendar.getInstance();
gc.setTime(
new
Date());
gc.set(Calendar.DAY_OF_MONTH,
1
);
String day_first
=
df.format(gc.getTime())
+
"
00:00:00
"
;
return
day_first;
}
//
當前月份的最后一天
public
static
String lastDay()
{
Calendar cal
=
Calendar.getInstance();
cal.add( cal.MONTH,
1
);
cal.set(cal.DATE,
1
);
cal.add(cal.DATE,
-
1
);
java.text.SimpleDateFormat df
=
new
java.text.SimpleDateFormat(
"
yyyy-MM-dd
"
);
String day_end
=
df.format(cal.getTime())
+
"
23:59:59
"
;
return
day_end;
}
//
距離當前月份N個月的第一天
public
static
String firstDay(
int
n)
{
java.text.SimpleDateFormat df
=
new
java.text.SimpleDateFormat(
"
yyyy-MM-dd
"
);
GregorianCalendar gc
=
(GregorianCalendar) Calendar.getInstance();
gc.setTime(
new
Date());
gc.set(Calendar.MONTH, gc.get(Calendar.MONTH)
+
n);
gc.set(Calendar.DAY_OF_MONTH,
1
);
String day_first
=
df.format(gc.getTime())
+
"
00:00:00
"
;
return
day_first;
}
//
距離當前月份N個月的最后一天
public
static
String lastDay(
int
n)
{
Calendar cal
=
Calendar.getInstance();
cal.add(cal.MONTH,
1
);
cal.set(cal.MONTH, cal.get(Calendar.MONTH)
+
n);
cal.set(cal.DATE,
1
);
cal.add(cal.DATE,
-
1
);
java.text.SimpleDateFormat df
=
new
java.text.SimpleDateFormat(
"
yyyy-MM-dd
"
);
String day_end
=
df.format(cal.getTime())
+
"
23:59:59
"
;
return
day_end;
}
}
posted on 2010-05-05 17:13
淡淡的回憶
閱讀(269)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
<
2010年5月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
統計
隨筆 - 10
文章 - 1
評論 - 3
引用 - 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
給我留言
查看公開留言
查看私人留言
隨筆檔案
2010年5月 (6)
2010年4月 (5)
搜索
最新評論
1.?re: js禁止右鍵,復制,粘貼,選擇
瀏覽器菜單欄--------》查看-------》查看頁面源代碼------》復制---》粘貼
--someone
2.?re: struts2中form提交到action中的中文亂碼問題解決辦法
其實只要把所有的編碼都設置成ut-8即可!我就想不通,utf-8是通用的編碼,干嘛又換成GBK?
--zcl
3.?re: struts2中form提交到action中的中文亂碼問題解決辦法
去更改default.properties,也許可以成功,但是這種做法是不被認可的。
可以使用struts.properties。
--grass
閱讀排行榜
1.?struts2中form提交到action中的中文亂碼問題解決辦法(1806)
2.?js禁止右鍵,復制,粘貼,選擇(1190)
3.?ssh調用存儲過程(1177)
4.?修改tomcat內存大小(1142)
5.?修改j2ee工程名,如何修改tomcat目錄下的webapps的工程目錄(982)
評論排行榜
1.?struts2中form提交到action中的中文亂碼問題解決辦法(2)
2.?js禁止右鍵,復制,粘貼,選擇(1)
3.?修改tomcat內存大小(0)
4.?修改j2ee工程名,如何修改tomcat目錄下的webapps的工程目錄(0)
5.?觸發器簡析(0)
Powered by:
BlogJava
Copyright © 淡淡的回憶
主站蜘蛛池模板:
合山市
|
施秉县
|
南靖县
|
英山县
|
鹤山市
|
磴口县
|
峡江县
|
凯里市
|
延长县
|
鹤庆县
|
阳高县
|
东平县
|
岳池县
|
吉木萨尔县
|
清丰县
|
偃师市
|
砀山县
|
吉林省
|
大城县
|
晋城
|
马龙县
|
高密市
|
盘山县
|
玛多县
|
阳春市
|
宜丰县
|
阳曲县
|
湟中县
|
榆树市
|
麻江县
|
修武县
|
双江
|
虹口区
|
紫金县
|
黄平县
|
兴和县
|
辽阳县
|
东阿县
|
长乐市
|
永新县
|
江山市
|