public static String nextDate(int day,String sDate) throws ParseException{
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
Calendar now = Calendar.getInstance();
Date date = df2.parse(sDate);
//System.out.println(date);
int day_next = day;
BigInteger big1 = new BigInteger( (24 * 60 * 60 * 1000) + "" );
BigInteger big2 = new BigInteger( day_next + "" );
BigInteger n = big1.multiply(big2);
//System.out.println( big1.multiply(big2) );
String ss = df2.format( date.getTime() + Long.parseLong(n+"") );
//System.out.println(ss);
return ss;
}
************************************
BigInteger big1 = new BigInteger( "2592000" );
BigInteger big2 = new BigInteger( "1000" );
BigInteger n = big1.multiply(big2);
System.out.println(n);
System.out.println(2592000 * 1000 );
输出结果:
2592000000
-1702967296
本文介绍了一个Java方法,用于计算从指定日期开始的若干天后的日期。通过使用BigInteger进行大数值运算,该方法能够准确地计算出未来日期,并以yyyy-MM-dd的格式返回。此外,文章还展示了BigInteger的乘法运算示例。
5万+

被折叠的 条评论
为什么被折叠?



