Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157797
  • 博文数量: 43
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 360
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-06 16:25
文章分类

全部博文(43)

文章存档

2015年(1)

2014年(12)

2008年(1)

2006年(29)

我的朋友

分类:

2006-07-27 15:51:55

文件: test.zip
大小: 0KB
下载: 下载
 
网上找不到JS版的,只好用Java写.
CalendarDTO
 
import java.io.Serializable;
public class CalendarDTO implements Serializable{
 private String label;
 private long value;
 public CalendarDTO(){
  
 }
 public String getLabel() {
  return label;
 }
 public void setLabel(String label) {
  this.label = label;
 }
 public long getValue() {
  return value;
 }
 public void setValue(long value) {
  this.value = value;
 }
}
TestCalendar
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;
public class TestCalendar {
 public static long oneDay=1*1000*60*60*24;
 public static int oneMonth=31;
 public static SimpleDateFormat sdf=new SimpleDateFormat("yyyy.MM.dd-EEE");
 
 public static void main(String[]args){
  Calendar t=Calendar.getInstance();
  Vector v=getMonthCalendar(t);
  Iterator it=v.iterator();
  while(it.hasNext()){
   CalendarDTO temp=(CalendarDTO)it.next();
   printCalendar(temp);
  }
 }
 
 private static Vector getMonthCalendar(Calendar today){
  long millis=today.getTimeInMillis();
  Vector result=new Vector();
  
  for(int i=0;i   CalendarDTO elem=new CalendarDTO();
   elem.setValue(millis);
   elem.setLabel(sdf.format(new Date(millis)));
   result.add(elem);
   millis+=oneDay;
   today.setTimeInMillis(millis);   
  } 
  return result;
 }
 
 private static void printCalendar(CalendarDTO cc){
  String display=cc.getLabel();
  display+="  "+cc.getValue();
  System.out.println(display);
  
 }
}
//result
2006.07.27-木  1153985502453
2006.07.28-金  1154071902453
2006.07.29-土  1154158302453
2006.07.30-日  1154244702453
2006.07.31-月  1154331102453
2006.08.01-火  1154417502453
2006.08.02-水  1154503902453
2006.08.03-木  1154590302453
2006.08.04-金  1154676702453
2006.08.05-土  1154763102453
2006.08.06-日  1154849502453
2006.08.07-月  1154935902453
2006.08.08-火  1155022302453
2006.08.09-水  1155108702453
2006.08.10-木  1155195102453
2006.08.11-金  1155281502453
2006.08.12-土  1155367902453
2006.08.13-日  1155454302453
2006.08.14-月  1155540702453
2006.08.15-火  1155627102453
2006.08.16-水  1155713502453
2006.08.17-木  1155799902453
2006.08.18-金  1155886302453
2006.08.19-土  1155972702453
2006.08.20-日  1156059102453
2006.08.21-月  1156145502453
2006.08.22-火  1156231902453
2006.08.23-水  1156318302453
2006.08.24-木  1156404702453
2006.08.25-金  1156491102453
2006.08.26-土  1156577502453
 
可以用作在下拉框中的日历.从当日到未来的31天.
Label可以本地化,Value是当日的毫秒数,作为后台传输.
还有点问题.~~待修改~~
 
 
阅读(1661) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~