我只是不想重新发明轮子:我需要在java中执行此操作(因为将vfox pro项目迁移到java):
来自GOMONTH()函数Visual fox pro文档:
返回给定日期或日期/时间表达式之前或之后指定月数的日期。
GOMONTH(dExpression | tExpression, nNumberOfMonths)
Parameters
dExpression
Specifies a date expression for which GOMONTH( ) returns the date.
tExpression
Specifies a date/time expression for which GOMONTH( ) returns the date.
nNumberOfMonths
Specifies the number of months from the date or date/time.If nNumberOfMonths is positive, GOMONTH( ) returns a date that is nNumberOfMonths months after the date or date/time. If nNumberOfMonths is negative, GOMONTH( ) returns a date that is nNumberOfMonths months before the date or date/time. For example, -1 means -31 days.
这是使用visual fox pro执行结果的简单示例:
? GOMONTH({^1998-12-31}, 2) && Displays 02/28/1999
? GOMONTH({^1998-12-31}, -2) && Displays 10/31/1998
答案 0 :(得分:1)
java.util.Calendar
的{{1}}方法会做你想要的。
例如,2个月前:
add()