datetime - Convert Unix Timestamp in Android with a static timezone that observes DST -
I have a problem finding out how to change a Unix timestamp for the normal date time of my Android app. In the case of my use, all reports of events are presented in the US Mountaineering Time. The server handles time and stores the correct unicetime. However, when my app receives the report time from the server, it will be sent to the U.S. The Unix timestamp is required to display in Mountain Timezone, where the user is located in the world. Apart from this, it is necessary to handle changes in GMT offset due to daylight saving.
Below I have tried, but I keep errors, it says that it can not solve the setTimeZone method and it expects "," in that function.
// todo: readable time string event reaget; String Eventagetime; EventUnixTime = eventData.getEventUnixtimeTime (); // Exits events in few seconds EventUnixTimeMilli = EventUnixTime * 1000; // Convert to Millisecond string timezone = "US / Mountain"; Calendar .SetetimeJohn (Timezone Timezone); Date EventDate = New Date (EventUnixTimeMilli); SimpleDetermined EventDataformat = New SimpleDateform ("YYA-MM-DD"); SimpleDetformFormatTimeTime = New SimpleDateform ("HHMM"); // Set string to use when setting text; EventRegDate = EventDateFormatter.format (EventDate); EventReg = EventTimeFormatter.format (EventDate);
After playing around something else I knew it.
Long EventVuxime = eventData.getEventUnixtimeTime (); Long EventUniqueTime = (EventUnxx * 1000); Date EventDate = New Date (Explosion Unixtime Milli); SimpleDetermined EventDataformat = New SimpleDateform ("YYA-MM-DD"); EventDateFormatter.setTimeZone (TimeZone.getTimeZone ("America / Mountain")); SimpleDetformFormatTimeTime = New SimpleDateform ("HHMM"); EventTimeFormatter.setTimeZone (TimeZone.getTimeZone ("America / Mountain")); String Event RegDate = EventDateFormatter.format (EventDate); String event REGTime = EventTimeFormatter.format (EventDate);
It is one of two strings that is YYYY-MM-DD and one that is always HHMM in Mountain Time.
Comments
Post a Comment