Created
December 15, 2016 16:10
-
-
Save fty4/39377def27e51a709508bc22c961979f to your computer and use it in GitHub Desktop.
Shows how to get current Time from GregorianCalendar-Type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date d = new Date(); | |
Calendar cal = Calendar.getInstance(); | |
cal.setTime(d); | |
GregorianCalendar c = new GregorianCalendar( | |
cal.get(Calendar.YEAR), | |
cal.get(Calendar.MONTH), | |
cal.get(Calendar.DAY_OF_MONTH), | |
cal.get(Calendar.HOUR_OF_DAY), | |
cal.get(Calendar.MINUTE), | |
cal.get(Calendar.SECOND)); | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH mm ss"); | |
System.out.println(sdf.format(c.getTime())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment