To get year and month from given timestamp I used this code. But giving a wrong answer for that.
long timestamp = Long.parseLong("1459239223");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timestamp);
System.out.println(cal.get(Calendar.YEAR));
But when using this it will give the connect answer as it should be. Any idea why this is happening.
Note: Java 7 OpenJDK is being used and a similar question is asked about Getting “unixtime” in Java.