1、使用Calendar类
/**
* 获取当前日期是星期几
*
* @param dt
* @return 当前日期是星期几
*/
public static String getWeekOfDate(Date dt) {
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)="" w="0;" return="" weekdays[w];="" }="" 2、使用simpledateformat格式化日期="" date="" date="new" date();="" simpledateformat="" datefm="new" simpledateformat("eeee");="" datefm.format(date);="" 注:格式化字符串存在区分大小写="" 对于创建simpledateformat传入的参数:eeee代表星期,如“星期四”;mmmm代表中文月份,如“十一月”;mm代表月份,如“11”;="">
create?table?table1?(
??id???int,
??name?varchar(8),
??createdate??date
);
insert?into?table1
select??1,?'name1',??to_date('2013-12-12',?'yyyy-mm-dd')??union??all
select??2,?'name2',??to_date('2013-12-13',?'yyyy-mm-dd')??union??all
select??3,?'name2',??to_date('2013-12-14',?'yyyy-mm-dd')??union??all
select??4,?'name2',??to_date('2013-12-15',?'yyyy-mm-dd')??union??all
select??5,?'name2',??to_date('2013-12-15',?'yyyy-mm-dd')??union??all
select??6,?'name2',??to_date('2013-12-12',?'yyyy-mm-dd');
select?distinct
??(select?count(1)?from??table1?t2?where?t1.createdate?>=?t2.createdate)?as?count,
??createdate??
from
??table1??t1
order?by
??createdate;
?count?|?createdate
-------+------------
?????2?|?2013-12-12
?????3?|?2013-12-13
?????4?|?2013-12-14
?????6?|?2013-12-15
(4?行记录)
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....