Example usage for java.util Calendar ZONE_OFFSET

List of usage examples for java.util Calendar ZONE_OFFSET

Introduction

In this page you can find the example usage for java.util Calendar ZONE_OFFSET.

Prototype

int ZONE_OFFSET

To view the source code for java.util Calendar ZONE_OFFSET.

Click Source Link

Document

Field number for get and set indicating the raw offset from GMT in milliseconds.

Usage

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.ZONE_OFFSET));

}

From source file:Main.java

public static void main(String args[]) {

    SimpleTimeZone stobj = new SimpleTimeZone(720, "US");

    // get offset
    int offset = stobj.getOffset(Calendar.ZONE_OFFSET);

    // check offset value       
    System.out.println("Offset is : " + offset);
}

From source file:Main.java

public static void main(String args[]) {

    TimeZone timezone = TimeZone.getTimeZone("Europe/Paris");

    // checking offset value for date      
    System.out.println("Offset value:" + timezone.getOffset(Calendar.ZONE_OFFSET));
}

From source file:MainClass.java

public static void main(String[] a) {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(new Date());

    System.out.println("ERA: " + calendar.get(Calendar.ERA));
    System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
    System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
    System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
    System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
    System.out.println("DATE: " + calendar.get(Calendar.DATE));
    System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
    System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
    System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
    System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
    System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
    System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000)));
    System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET) / (60 * 60 * 1000)));
}

From source file:Main.java

public static int timeZoneOffset() {
    Calendar cal = Calendar.getInstance();
    int offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / (60 * 1000);
    return offset;
}

From source file:Main.java

public static long addUTCTime(long timeMillis) {

    Calendar cal = Calendar.getInstance(Locale.getDefault());
    int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);
    int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);

    timeMillis = timeMillis + zoneOffset + dstOffset;//        if (start.after(end)) {

    return timeMillis;
}

From source file:Main.java

public static int dayFrom_CalendarLocal(Calendar c) {
    return dayFrom_Milliseconds(c.getTimeInMillis() + c.get(Calendar.ZONE_OFFSET));
}

From source file:Main.java

public static Long GetUTCTime() {
    Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
    int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
    int dstOffset = cal.get(Calendar.DST_OFFSET);
    cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));
    return cal.getTimeInMillis();
}

From source file:Main.java

/**
 * This method is used to generate random number between given range.
 *///from w  ww. j a va  2  s.  com
public static long getRandomNumberBetween() {
    Calendar rightNow = Calendar.getInstance();
    long offset = rightNow.get(Calendar.ZONE_OFFSET) + rightNow.get(Calendar.DST_OFFSET);
    long sinceMidnight = (rightNow.getTimeInMillis() + offset) % (24 * 60 * 60 * 1000);
    return sinceMidnight;
}

From source file:Main.java

public static long getUtcMillis(final long millis) {
    Calendar calendar = getCalendar(millis);
    long offset = calendar.get(Calendar.ZONE_OFFSET);
    return millis - offset;
}