We have a java date object which is in a different timezone then the timezone of machine. We want to date, month and year of the date without changing the timezone.
Also the function is unaware of the date's timezone. All it is getting is java date object with date in correct timezone and java Date does not provide Date.getTimeZone().
Current Date.getDate()
, Date.getMonth()
and Date.getYear()
does that but its deprecated and getYear()
subtracts date from 1900. I don't know why.
What is the preferred way of extracting such information?
For e.g. If date object contains date "20 Jan 2016 2:00 AM" in EST timezone, we would like to retain it that way even if system is running in CST. So the output should be Date: 20, Month: 1, Year: 2016.