[英]Calendar in Java
I have to add the no of delays to calendar type , and wants the new date in Calendar Type only. 我必须在日历类型中添加no的延迟,并且只希望日历类型中的新日期。
limitDate = orderDate + settlementDelay.
where 哪里
limitDate = java.util.Calendar
orderDate = java.util.Calendar
settlementDelay = int
I tried something like this : 我尝试过这样的事情:
Calendar limitDate = order.getOrderDate().add(Calendar.DATE,settlementDelay);
But its giving me the 但是它给了我
Type mismatch error: Cannot convert from void to Calendar.
Can anybody help me out? 有人可以帮我吗?
You're getting this error because Calendar#add() method doesn't return anything (see void) and adds the input date/month/year etc in the supplied Calendar instance itself. 您收到此错误消息是因为Calendar#add()方法不返回任何内容(请参见void),并在提供的Calendar实例本身中添加了输入日期/月份/年份等。
EDIT: If you really need a new instance then use code like this: 编辑:如果您确实需要一个新实例,则使用如下代码:
Calendar limitDate = Calendar.getInstance();
limitDate.setTime( orderDate.getTime() );
limitDate.add(Calendar.DATE, settlementDelay);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.