//date()
Date date = new Date();
//date format java-date-format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-12");
//java-dtoc date to character
String dateString = sdf.format(date);
System.out.println(dateString);
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-03-04");
Calendar cal = Calendar.getInstance();
cal.setTime(temp);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1; // the variable is 3
int day = cal.get(Calendar.DAY_OF_MONTH);
沒有留言:
張貼留言