public class App { public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy"); String result = sdf.format(date); System.out.println(result); } }
再发一个:public class App { public static void main(String[] args) throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); String result = sdf.format(date); System.out.println(result); // 打印结果: 28Apr11 } }
public static void main(String[] args) throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); String result = sdf.format(date); System.out.println(result); // 打印结果: 28Apr11 }这么写就可以了 楼上是正解
但是这里“2011-04-25”是一个String类型的参数传进函数中的,不是使用Date date = new Date()得到的一个Date类型
public class App {
public static void main(String[] args) {
Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy"); String result = sdf.format(date); System.out.println(result);
}
}
public static void main(String[] args) throws ParseException {
Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); String result = sdf.format(date); System.out.println(result);
// 打印结果: 28Apr11
}
}
Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); String result = sdf.format(date); System.out.println(result);
// 打印结果: 28Apr11
}这么写就可以了 楼上是正解
先把“2011-04-25”转成Date
在转成你说的那种格式。
SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy"); String formartDate = sdf.format(date);