Learn From:http://blog.csdn.net/sunhuwh/article/details/39161323 public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = null; cale = Calendar.getInstance(); int year = cale.get(Calendar.YEAR); int month =
public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = null; cale = Calendar.getInstance(); int year = cale.get(Calendar.YEAR); int month = cale.get(Calendar.MONTH) + 1; int day = cale.get(Calendar.DATE);
private void setTilteMessage(){ BaseDao dao = new BaseDao(); String titleData = dao.getLatestData(); dao.closeDB(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { Date d
方法一可以使用date的getTime()方法来将当前日期格式的时间转换为毫秒数,进而相减. long systime = new Date().getTime();//当前系统时间 long oldtime = old.getTime();//相比较的时间 Long time = (systime - oldtime);//相差毫秒数 方法二则使用calendar 的getTimeInMillis() 方法来将当前日期格式的时间转换为毫秒数. Calendar no
原文地址:http://bdcwl.blog.163.com/blog/static/765222652009104171521/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = sdf.parse("2009-11-04");//String-->Date String sdate = sdf.format(date );// Data-->String Ti