h2-database

关于时间的计算方式

Date mydate=new Date();

auditrank.setSetdate(mydate);

 此时数据库里的时间存储的是:2011-7-12 14:30:25

      

      Date mydate=new Date();

       SimpleDateFormat formatt=new SimpleDateFormat("MM/dd/yyyy");
        String formatteddate=formatt.format(mydate);
        java.text.SimpleDateFormat formatter=new java.text.SimpleDateFormat("MM/dd/yyyy");
        java.util.Date date=formatter.parse(formatteddate);
        auditrank.setSetdate(date);

此时数据库的时间存储的是:2011-7-12

 

 

两个时间之间的时长:

SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); 

 java.util.Date date= myFormatter.parse("2003-05-1");    

java.util.Date mydate= myFormatter.parse("1899-12-30");   

long  day=(date.getTime()-mydate.getTime())/(24*60*60*1000);

 

分类:

技术点:

相关文章:

  • 2021-11-06
  • 2021-11-05
  • 2021-11-01
  • 2021-09-17
  • 2021-11-14
  • 2021-10-07
猜你喜欢
  • 2021-08-29
  • 2021-07-19
  • 2021-08-12
  • 2021-03-07
  • 2021-11-02
  • 2021-09-19
  • 2021-11-03
相关资源
相似解决方案