方法1: SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd EEEE"); Date date = new Date(); String strToday = bartDateFormat.format(date).toString();方法2: Calendar cd=Calendar.getInstance(); System.out.println(cd.getTime());
Calendar c=Calendar.getInstance(); int y=c.get(Calendar.YEAR); int m=c.get(Calendar.MONTH); int d=c.get(Calendar.DAY_OF_MONTH); int dd=c.get(Calendar.DATE);
Calendar calendar=new GregorianCalendar(2004,6-1,1); int max=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); System.out.println("days:"+max);
Calendar c=Calendar.getInstance(); int y=c.get(Calendar.YEAR); int m=c.get(Calendar.MONTH); int d=c.get(Calendar.DATE); int date=c.get(Calendar.DAY_OF_WEEK);
比如说获取当前年year Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR);
取系统当前时间:年月日时分秒java.util.Date today = new java.util.Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String sdate=formatter.format(today);存入数据库 String sql = "insert into tabforum (tposttime) values (to_date('"+sdate+"','YYYY/MM/DD HH24:MI:SS'))";
Calendar now = Calendar.getInstance(); System.out.println(now.get(Calendar.DAY_OF_WEEK)-1); 这是求星期,其它类似
Calendar now = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日E"); System.out.println(sdf.format(now.getTime()));
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd EEEE");
Date date = new Date();
String strToday = bartDateFormat.format(date).toString();方法2:
Calendar cd=Calendar.getInstance();
System.out.println(cd.getTime());
int y=c.get(Calendar.YEAR);
int m=c.get(Calendar.MONTH);
int d=c.get(Calendar.DAY_OF_MONTH);
int dd=c.get(Calendar.DATE);
int max=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println("days:"+max);
int y=c.get(Calendar.YEAR);
int m=c.get(Calendar.MONTH);
int d=c.get(Calendar.DATE);
int date=c.get(Calendar.DAY_OF_WEEK);
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sdate=formatter.format(today);存入数据库
String sql = "insert into tabforum (tposttime) values (to_date('"+sdate+"','YYYY/MM/DD HH24:MI:SS'))";
System.out.println(now.get(Calendar.DAY_OF_WEEK)-1);
这是求星期,其它类似
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日E");
System.out.println(sdf.format(now.getTime()));