274. } catch (Exception e) {
275. result.setText("输入的日期有误!");
276. return null;
277. }
278. return cal;
279. }
280.
281. /**
282. * 获得当前日期是哪个星期
283. */
284. public void translate(){
285. result.setHorizontalAlignment(JTextField.LEFT);
286. inputing = false;
287. SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
288. try {
289. int i =
calendar.get(Calendar.DAY_OF_WEEK);
290. String weekStr[] = {
291. "",
292. "星期日",
293. "星期一",
294. "星期二",
295. "星期三",
296. "星期四",
297. "星期五",
298. "星期六",
299. };
300. result.setText(format.format(calendar.getTime())+"是" + weekStr[i]);
301. } catch (Exception e) {