현재 날짜 시간 LocalDateTIme.now()
과 issueDateTime
이라는 오브젝트의 다른 숫자를 일 단위로 찾아야합니다. 또한 시간을 시작으로 issueDateTime
부터 계산됩니다. 즉, issueDateTime
이 2012 년 4 월 12 일 오후 5:00 일인 경우 오후 5 시가 아닌 12 시가 계산되어야합니다. 나는 발행일과 현재 날짜의 차이를 일 단위로 찾은 다음, rentTariff/day를 곱하여 방법 amountPayable()
의 금액을 반환합니다. 감사합니다두 LocalDateTIme 오브젝트 간의 차이 일수
public class RentOut {
private int rentalTariff ;
private LocalDateTime dateTime;
private String rentedTo;
private LocalDateTime returnDateTime;
public RentOut(int rentalTariff) {
this.rentalTariff = rentalTariff;
}
public void RentIt(LocalDateTime dateTime, String rentedTo) {
this.dateTime = dateTime;
this.rentedTo = rentedTo;
this.returnDateTime = dateTime.plusHours(24);
}
public LocalDateTime getRentDateTime() {
return dateTime;
}
public LocalDateTime returnDateTime() {
return returnDateTime;
}
public String getCustomerName() {
return rentedTo;
}
public int amountPayable() {
//return LocalDateTime.now().minus(dateTime)*rentalTariff;
}
}
문제를 보여주는 짧지 만 완전한 예제를 보여주십시오 - 단지 2 개의 LocalDateTime 값을 가진 간단한 콘솔 앱과 현재 문제를 어떻게 해결하려고하는지에 대해 설명합니다. –
코드가 추가되었습니다. –
그것은 짧지 만 완전한 예가 아닙니다. 그렇습니까? 샘플 데이터가 포함되어 있지 않으며 불필요한 비트가 많이 있습니다. 이 경우에 짧지 만 완전한 예제는 약 3 행의 코드가있는'main' 메소드를 포함하는 클래스 일 가능성이 높습니다. –