Java TimeZone getOffset() Method

The getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) method of TimeZone class is used to get the offset of time zone, and the current date. This offset is used to get the local time.

Syntax

This method is overloaded in the following ways.

Parameters

Era - it is the given date era.

Year - it is the given date year.

Month - it is the given date month

Day - it is the given date of the day-in-month.

DayOfWeek - it is the given date of the day-of-week.

Milliseconds - it is the milliseconds in the day.

Date: It is the date specified as the long type of which, the offset will be returned.

Returns

It returns the offset in milliseconds.

Example 1

Output:

Offset value :3600000

Example 2

Output:

Offset value :0

Example 3

Output:

Offset value :50400000

Example 4

Output:

Offset value :-39600000

Example 5

Output:

Offset value :10800000

Example 6

Output:

Offset value :-39600000