修改日期类型(Java)
这里需要有关日期类型的帮助 我正在使用以下参数管理一个信用卡类修改日期类型(Java),java,date,increment,Java,Date,Increment,这里需要有关日期类型的帮助 我正在使用以下参数管理一个信用卡类 public class CreditCard extends Card{ Date monthlyFee; double amount2pay; public CreditCard(StandardAccount yourAssociatedBankAccount,Date monthlyFeeDay) { super(yourAssociatedBankAccount); monthlyFee=monthlyFe
public class CreditCard extends Card{
Date monthlyFee;
double amount2pay;
public CreditCard(StandardAccount yourAssociatedBankAccount,Date monthlyFeeDay) {
super(yourAssociatedBankAccount);
monthlyFee=monthlyFeeDay;
cardType="Credit Card";
}
创建信用卡时,我必须设置MonthlyFeeDay(例如“今天+30天”)
以下函数必须创建信用卡
public void createCreditCard(StandardAccount anAccount){
Date today= new Date();
Card newCard= new CreditCard(anAccount,today);
anAccount.addCard(newCard);
cardsList.add(newCard);
}
事实上,我不知道如何将变量“today”增加30天。我不知道如何确定下个月的日期。
有什么提示吗?您可以使用日历进行此操作
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, 30);
Date date = c.getTime();
这里使用的是什么Java版本?请参考此