这是一个家庭作业。我必须执行以下操作:
private Date dateCreated 哪个存储,当对象被创建时。
private Date dateCreated;
dateCreated 的 getter 方法。
public Date getDateCreated() {
return dateCreated;
}
并且必须实现这个主要方法:
public static void main(String[] args){
Account a=new Account(1122,20000,4.5);
a.withdraw(2500);
a.deposit(3000);
System.out.println(a.getBalance());
System.out.println(a.getMonthlyInterestRate()+"%");
System.out.println(a.getDateCreated()); // or another method what can get
//time when the object created
}
我试过使用 getTime() 但我不知道如何在我的代码中使用。我看到了一些解决方案,但它总是为此创建了另一个类。我想要一个简单的解决方案。(可能在声明 dateCreated 字段时)