我有 GregorianCalendar 实例,需要使用 SimpleDateFormat(或者可以与日历一起使用但提供所需的 #fromat() 功能的东西)来获得所需的输出.请建议解决方法与永久解决方案一样好.
I've got GregorianCalendar instances and need to use SimpleDateFormat (or maybe something that can be used with calendar but that provides required #fromat() feature) to get needed output. Please, suggest work arounds as good as permanent solutions.
试试这个:
Calendar cal = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
dateFormat.setTimeZone(cal.getTimeZone());
System.out.println(dateFormat.format(cal.getTime()));
这篇关于如何将 SimpleDateFormat 与日历一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!