如题,想按照周,查询日程信息。比如说:根据今天日期2010年4月16日,查处所在的本周的日程信息。点击“上一周”,就查询出上一周的日程;点击“下一周”,就查询出上一周的日程。
解决方案 »
- 为什么我的文件导入放到Linux服务器上就出问题了
- SSH代码生成器,来拿。。。。
- 自定义循环标签的循环次数问题
- jsp问题:如何防止界面挥发
- 各位大姐大哥,帮助解决这个问题了,求求你们了
- 初学spring遇到的问题
- 一个很急的问题?jsp读oracle数据库,字符型是乱码?
- 关于myeclipse的问题???请教高人指教!
- Instantiation of bean failed; nested exception is org.springframework.beans.Bean
- 要做中英文两套,这样的网站怎么设计?
- json 缺少对象错误(IE8),请求高手帮忙看看
- quartz中简单任务执行
这个还是比较简单的。Google能查到吧
oracle 按周查询
function getFirstDateOfWeek(){
var theDate = new Date();
var firstDateOfWeek;
theDate.setDate(theDate.getDate() - theDate.getDay() + 1); //
firstDateOfWeek = theDate;
return firstDateOfWeek;
}
//得到每周的最后一天(周日)
function getLastDateOfWeek(){
var theDate = new Date();
var lastDateOfWeek;
theDate.setDate(theDate.getDate() - theDate.getDay() + 1 + 6); //
lastDateOfWeek = theDate;
return lastDateOfWeek;
}
//得到当前月的第一天
function getFirstMonthDate(){
var year = new Date().getFullYear();
var month = new Date().getMonth();
if (month<10){
month = "0"+month;
}
var myDate = new Date(year,month,01);
}
//得到当前月的最后一天
function getLastMonthDate(){
var year = new Date().getFullYear();
var month = new Date().getMonth()+1;
var myDate = new Date(year,month,0);
}太巧了 我刚写不久的 呵呵 上周的就用本周的再减去7天就可以了
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
public class Common
{
private static final Common common = new Common();
private Common()
{
}
public static Common getCommon()
{
return common;
}
public Calendar getDate()
{
Calendar cal = new GregorianCalendar();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_WEEK, (9-cal.get(Calendar.DAY_OF_WEEK))%7);
return cal;
}
public List getWeekDate()
{
List list = new ArrayList();
Calendar cal = this.getDate();
SimpleDateFormat d=new SimpleDateFormat("yyyy-MM-dd");
for(int i=0;i<7;i++)
{
list.add(d.format(cal.getTime()));
cal.roll(Calendar.DAY_OF_YEAR,true);
}
return list;
}
public static void main(String args[])
{
List list = Common.getCommon().getWeekDate();
for(int i=0;i<list.size();i++)
{
System.out.println(list.get(i));
}
}
}