萍聚社区-德国热线-德国实用信息网

 找回密码
 注册

微信登录

微信扫一扫,快速登录

萍聚头条

查看: 520|回复: 0

1-1-8-14 如何使用时间函数的一问

[复制链接]
发表于 2003-2-6 17:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册 微信登录

x

  1. 发信人: [email]silver.bbs@bbs.nankai.edu.cn[/email] (书剑走天涯), 信区: Java
  2. 标  题: Re: 如何使用时间函数的一问
  3. 发信站: 我爱南开站 (Thu Oct 17 17:29:08 2002)
  4. 转信站: SMTH!maily.cic.tsinghua.edu.cn!news.happynet.org!NanKai



  5. y用import java.util.Calendar;试试

  6. 我的一个测试小程序:

  7.     Calendar c = Calendar.getInstance();
  8.     Date t1 = c.getTime();//当前时间
  9.     System.out.println(" current time : "+t1);
  10.     c.add(Calendar.DATE,1);//Date Arithmetic function.取一天后
  11.     Date tt = c.getTime();//一天后的当前时间
  12.     System.out.println(" time after a day : "+tt);

  13. 在jb6中运行的结果是:

  14. current time : Thu Oct 17 17:25:28 CST 2002
  15. time after a day : Fri Oct 18 17:25:28 CST 2002

  16. 在时间片来说可能会有在运行顺序上会有一些时间的差距.
  17. 不过偶觉得可以忽略吧...

  18. 如果偶理解错误就请扔板砖吧//bow

  19. 【 在 ahdoh (小辉) 的大作中提到: 】
  20. : 比如 当前时间
  21. : Date nowDate= new Date()
  22. : 那如何判断一天以后的此刻?  即 nowDate+(1天) 如何表示?
  23. : 我看了文档  不是很明白 大侠指点一下。



  24. 发信人: [email]silver.bbs@bbs.nankai.edu.cn[/email] (书剑走天涯), 信区: Java
  25. 标  题: Re: 如何使用时间函数的一问
  26. 发信站: 我爱南开站 (Thu Oct 17 17:30:55 2002)
  27. 转信站: SMTH!maily.cic.tsinghua.edu.cn!news.happynet.org!NanKai


  28. 参看jdk源码里面Calendar对这个function的解释:

  29.     /**
  30.      * Date Arithmetic function.
  31.      * Adds the specified (signed) amount of time to the given time
  32. field,
  33.      * based on the calendar's rules. For example, to subtract 5 days
  34. from
  35.      * the current time of the calendar, you can achieve it by calling:

  36.      * <p>add(Calendar.DATE, -5).
  37.      * @param field the time field.
  38.      * @param amount the amount of date or time to be added to the
  39. field.
  40.      */

  41. 应该是没有问题的...:)

  42. best wishes

  43. 【 在 silver (书剑走天涯) 的大作中提到: 】
  44. :  y用import java.util.Calendar;试试
  45. :  我的一个测试小程序:
  46. :     Calendar c = Calendar.getInstance();
  47. :     Date t1 = c.getTime();//当前时间
  48. :     System.out.println(" current time : "+t1);
  49. :     c.add(Calendar.DATE,1);//Date Arithmetic function.取一天后
  50. :     Date tt = c.getTime();//一天后的当前时间
  51. :     System.out.println(" time after a day : "+tt);
  52. : 在jb6中运行的结果是:
  53. :  current time : Thu Oct 17 17:25:28 CST 2002
  54. : .................(以下省略)


复制代码
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
您需要登录后才可以回帖 登录 | 注册 微信登录

本版积分规则

手机版|Archiver|AGB|Impressum|Datenschutzerklärung|萍聚社区-德国热线-德国实用信息网 |网站地图

GMT+2, 2024-5-22 05:17 , Processed in 0.052180 second(s), 16 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表