KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have my app hosted in a London Server. I am in Madrid, Spain. So the timezone is -2 hours. How can I obtain the current date / time with my time zone. Date curr_date = new Date(System.currentTimeMillis()); e.g. Date curr_date = new Date(System.currentTimeMillis("MAD_TIMEZONE")); With Joda-Time DateTimeZone zone = DateTimeZone.forID("Europe/Madrid"); DateTime dt = new DateTime(zone); int day = dt.getDayOfMonth(); int year = dt.getYear(); int month = dt.getMonthOfYear(); int hours = dt.getHourOfDay(); int minutes = dt.getMinuteOfHour();
Tags (comma-separated)
Save Edits
Cancel