假如现在是10:30,我需要获取2:45分钟之前是什么时间 怎么获取? 本人新书,希望能给出代码指点!谢谢了!!
------解决方案--------------------
- Java code
Calendar calendar = Calendar.getInstance(); calendar.set(2012, 8, 17, 10, 30, 00); calendar.add(Calendar.MINUTE, -(2 * 60 + 45)); Date date = calendar.getTime(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println(df.format(date));