swing中的 联动日历

chl0311 2008-01-07 08:58:19
在数据库中存的有 生日 datetime类型的 例如:1988-03-11 00:00:00:00,让在swing中如何显示出来为 1988-03-11并且在JComboBox显示,在瑞年的时候2月分只有29天,其他年份有28天,1,3,5,7,8,10,12月有31天,4,6,9,10,11月有30天
谢谢各位
...全文
124 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shengli_liao 2008-01-18
  • 打赏
  • 举报
回复
public class DateSpinner extends JSpinner{
public DateSpinner(String formatText) {
SpinnerDateModel model = new SpinnerDateModel();
this.setModel(model);

DateEditor editor = new DateEditor(this,formatText);
JTextField field = editor.getTextField();
field.setHorizontalAlignment(field.CENTER);
field.setFont(font);
this.setEditor(editor);

setOpaque(true);
updateUI();
}
}
tiger_yuan 2008-01-07
  • 打赏
  • 举报
回复
public String getTime(){
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = sdf1.format(new Date());
return time;
}//new Date()-系统当前时间

public String getDay(){
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
String day = sdf1.format(new Date());
return day;
}

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧