title: get the current age from jdatechooser in java
body: <p>I want to calculate my age from date chooser and when i press the button my current age will appear..</p>
  
  <p>how can I do that?</p>
  
  <p>I can do this through this code:</p>
  
  <pre><code>Calendar cal = new GregorianCalendar(1999, 1, 1); //I WANT THIS AGE TO BE INPUT FROM DATESHOOSER)
  
  Calendar now = new GregorianCalendar();
  int res = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
  if ((cal.get(Calendar.MONTH) &gt; now.get(Calendar.MONTH))
      || (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH) &amp;&amp; cal.get(Calendar.DAY_OF_MONTH) &gt; now
          .get(Calendar.DAY_OF_MONTH))) {
    res--;
  }
  System.out.println(res);
  
  jTextField3.setText(Integer.toString(res));  
  </code></pre>
  
  <p>But I want to make an input from date chooser as my age and I can calculate it by pressing a jbutton</p>