如何使用SimpleDateFormat与日历? [英] How can I utilize SimpleDateFormat with Calendar?
本文介绍了如何使用SimpleDateFormat与日历?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有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与日历?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文