java时间操作

来源:互联网 发布:xd破解id软件 编辑:程序博客网 时间:2024/06/02 13:02

     Format now = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
     Calendar calTwo =test(Calendar.getInstance(), -2);
     Calendar calOne =test(Calendar.getInstance(), -1);
     
     //生效时间传当前时间的前两天,结束时间传当前时间前一天
     String twoTime=now.format(calTwo.getTime());
     String oneTime=now.format(calOne.getTime());

 public Calendar test(Calendar c, int day) {
  c.add(Calendar.DATE, day);
  return c;
 }

oracle 修改时间字段值

update tblName so set so.receive_time = to_date('2014-02-13 13:00:00','yyyy-mm-dd hh24:mi:ss') where so.sub_order_id = ' '

按指定格式获取时间

import java.util.*;
import java.text.*;
public class TestDate {
  public static void main(String args[]) {
  Date today=new Date();
  SimpleDateFormat f=new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
  String time=f.format(today);
  System.out.println(time);
  }
}
格式里的时如果用hh表示用12小时制,HH表示用24小时制。MM必须是大写!

 

原创粉丝点击