Am new to Java and did not understand following piece of code from here
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
After creating and instance of class SimpleDateFormat
, which is from the java.text
package, the setTomeZone
method of the java.util
package is being used.
Can any one please help me understand why we used setTimeZone
method with instance of SimpleDateFormat
class and NOT with instance of Calendar
class?
Note: I went through a couple of articles that tell me how to call a method from another Java class or Java package. However this seemed different to me. I also noticed Calendar
is an abstract class but unable to understand here.