//日期时间格式化
public static void main(String[] args)
{
Date date=new Date(System.currentTimeMillis());
DateFormat df=new SimpleDateFormat("yyyy-MM-dd,hh-mm-ss-SS");
String str=df.format(date);//将日期按格式化输出
System.out.println(str);
DateFormat df2=new SimpleDateFormat("yyyy-MM-dd,hh-mm-ss-SS");
Date mydate=new Date();
try {
mydate= df2.parse("2017-03-03,12-56-32-444");
}
catch (ParseException e) {
e.printStackTrace();
}
System.out.println(mydate);
}
public static void main(String[] args)
{
Calendar cal;
cal=new GregorianCalendar();
cal.set(2011,Calendar.SEPTEMBER,10,2,3,4);
Date d=cal.getTime();
System.out.println(d);
int weekofm=cal.get(Calendar.WEEK_OF_MONTH); ///获取日期的相关信息
System.out.println(weekofm);
}