Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Date/Time in UTC Format

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 214
    Comment on it

    UTC stands for Coordinated Universal Time. It is the common time standard across the world.
    In order to get the date-time in UTC, we need to set the timezone in UTC, like this:-
    Step 1
    Define your format in which you want to get date/time:-

    String format = "yyyy/MM/dd HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    

    Step 2
    Set the TimeZone of SimpleDateFormat in UTC

    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    

    Step 3
    Get date/time string in UTC

    sdf.format(date)
    

    Now you can parse this UTC String in date datatype.

    Note:- In order to parse String in Date visit this link

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: