50,527
社区成员
发帖
与我相关
我的任务
分享
Date now=new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(df.format(now));
df = new SimpleDateFormat("yyyy-MM");
System.out.println(df.format(now));
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateSplit {
/**
* @param args
*/
public static void main(String[] args) {
Date now=new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(df.format(now));
df = new SimpleDateFormat("yyyy-MM");
System.out.println(df.format(now));
}
}