Gets Date with UTC time zone - Android java.util

Android examples for java.util:Timezone

Description

Gets Date with UTC time zone

Demo Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**//from w  ww .j av  a2  s  .c o  m
     * Gets Date with UTC time zone
     * @param date is concrete date
     * @return new instance calendar
     */
    public static Calendar getCalendarUTC(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
        return calendar;
    }
}

Related Tutorials