숙제입니다. 다음을 구현해야합니다.Java에서 객체를 만들 때 구현 날짜는 어떻게됩니까?
개인 날짜 date 개체가 생성 된 날짜 storeCreated.
private Date dateCreated;
getter method for dateCreated.
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()를하지만 난 내 코드에서 사용할 수있는 방법을 모르겠어요. 몇 가지 해결책을 발견했지만 항상 다른 수업을 만들었습니다. 간단한 해결책을 원합니다. 당신이 제공하는 (당신이 명시 적으로 설정할 수 있습니다,
public Account(...<params>...)
{
... <usual param initialization that you already have> ...
this.dateCreated = new Date(); // sets to the current date/time
}
을 OR :
이 내용을 명확히해야합니다. – jayunit100
감사합니다. – blaces