public String setPickedDate() { if (day.equals("")) return day; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy"); java.util.Calendar cal = java.util.Calendar.getInstance(); cal.set(year, month, Integer.parseInt(day)); return sdf.format(cal.getTime()); }
public void displayDate() { for (int x = 7; x < button.length; x++) button[x].setText(""); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy"); java.util.Calendar cal = java.util.Calendar.getInstance(); cal.set(year, month, 1); int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK); int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH); for (int x = 6 + dayOfWeek, day = 1; day <= daysInMonth; x++, day++) button[x].setText("" + day); l.setText(sdf.format(cal.getTime())); d.setTitle("Date Picker"); }
public static JLabel getTime() { // Here are some things to deal with the clock in the status panel final java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("HH:mm:ss"); final JLabel timeLabel = new JLabel(sdf.format(new java.util.Date())); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { timeLabel.setText(sdf.format(new java.util.Date())); } }; new javax.swing.Timer(1000, al).start(); return timeLabel; }