获取当前时间:
获取当前的时间:
获取年月:
获取年、月日:
import java.text.SimpleDateFormat;
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss ");
Date curDate = new Date(System.currentTimeMillis());//获取当前时间
String str = formatter.format(curDate);
获取当前的时间:
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = sDateFormat.format(new java.util.Date());
获取年月:
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM");
String date=sdf.format(new java.util.Date());
获取年、月日:
Calendar c = Calendar.getInstance();
年= c.get(Calendar.YEAR);
月 = c.get(Calendar.MONTH) + 1;
日 = c.get(Calendar.DAY_OF_MONTH);