I have the code below, which produces this:
2012-07-28 17:30:23
Which is what I want. But if I want to extract all the numbers on their own to assign to variables, do I need to make a RegEx or is there some way to simply extract these from the SimpleDateFormat?
SimpleDateFormat dateFormatUCT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormatUCT.setTimeZone(TimeZone.getTimeZone("UCT"));
//Time in UCT
String date = dateFormatUCT.format(new Date());
System.out.println(date);
You have a Date. Convert if to a GregorianCalendar, and ask every field to the GregorianCalendar: