Java 我想设置simpledate值,以便比较它们以获得年龄

Java 我想设置simpledate值,以便比较它们以获得年龄,java,input,simpledateformat,Java,Input,Simpledateformat,我如何将dateBirth和dateToday设置为等于我以mm/dd/yyyy格式输入的值 public class AgeClientFL { public static void main(String [] args){ int month, day, year; day = UtilsFL.readInt("Enter birth day: ",false); // String mode month = UtilsFL.readInt("Enter birth mo

我如何将
dateBirth
dateToday
设置为等于我以mm/dd/yyyy格式输入的值

public class AgeClientFL {

public static void main(String [] args){

  int month, day, year;

  day = UtilsFL.readInt("Enter birth day: ",false); // String mode
  month = UtilsFL.readInt("Enter birth month: ",false);
  year = UtilsFL.readInt("Enter birth year: ",false);

  SimpleDate dateBirth = new SimpleDate();

  day = UtilsFL.readInt("Enter todays day: ",true); // JOptionPane mode
  month = UtilsFL.readInt("Enter todays month: ",true);
  year = UtilsFL.readInt("Enter todays year: ",true);

  SimpleDate dateToday = new SimpleDate();




   }
}

但是,这个
java.util.Date
并不是很有用,所有东西都不推荐使用,您只能使用getTime()。
java.sql.Date
java.util.GregoriaCalendar
更有用。我想了解一下,你可以很容易地得到年、月、日等。默认情况下Java中没有类
SimpleData
。你看过SimpleData类的文档/源代码了吗?
import java.text.SimpleDateFormat;
import java.util.Date;

...

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date date = sdf.parse(dateString);
System.out.println(sdf.format(date));