title: Date in JLabel (Java bean)
body: <p>I trying to implement current date using get set method in Java. It's a Java bean, and I should be able to get the date when I import in the GUI. My problem is it doesn't show the current date, it just shows the Jlabel text.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>package datebean;
  
  import javax.swing.border.EtchedBorder;
  import javax.swing.*;
  import java.awt.FlowLayout;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  /**
   * A JavaBean for displaying dates.
   */
  public class DateBean extends JPanel {
      Date date = new Date();
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      JLabel lblDay = new JLabel("dd"),
              lblMonth = new JLabel("mm"),
              lblYear = new JLabel("yy");
  
      public DateBean() {
          this.setLayout(new FlowLayout());
          this.setBorder(new EtchedBorder());
          this.add(lblDay);
          this.add(lblMonth);
          this.add(lblYear);
      }
  
      public void setDay(String day) {
          day = dateFormat.format(date);
          lblDay.setText(day);
      }
  
      public String getDay(String day){
          return day;
      }
  
      public void setMonth(String month) {
          month = dateFormat.format(date);
          lblMonth.setText(month);
      }
  
      public String getMonth(String month){
          return month;
      }
  
      public void setYear(String year) {
          year = dateFormat.format(date);
          lblYear.setText(year);
      }
  
      public String getYear(String year){
          return year;
      }    
  }
  </code></pre>