To extract the information from a Date-Time we can use Calendar class in combination with the built in time methods.
Lets say we have a custom field of type date-time called DateTime_c
We want to extract from the value of this field the following:
For year, month, day we use the built in functions as follows:
Calendar calendar = Calendar.getInstance();
Now we have access to all the methods of this class.
So we use MINUTE , HOUR_OF_DAY , SECOND, MILLISECOND as follows: