Java:
int offset = TimeZone.getDefault().getRawOffset() + TimeZone.getDefault().getDSTSavings();
long now = System.currentTimeMillis() - offset;
Kotlin:
val offset: Int = TimeZone.getDefault().rawOffset + TimeZone.getDefault().dstSavings
val now: Long = System.currentTimeMillis() - offset
More Related Contents:
- How to use the Firebase server timestamp to generate date created?
- Android/Firebase – Error while parsing timestamp in GCM event – Null timestamp
- How set the android:gravity to TextView from Java side in Android
- Getting screen width on API Level 30 (Android 11): getDefaultDisplay() and getMetrics() are now deprecated. What should we use instead?
- LayoutManager for RecyclerView Grid with different cell width
- Emulator problem in Android
- Keyboard hides BottomSheetDialogFragment
- Spinner onItemSelected called erroneously (without user action)
- FragmentActivity can not be tested via ActivityInstrumentationTestCase2
- Android CollapsingToolbarLayout with custom View
- LongClick event happens too quickly. How can I increase the clicktime required to trigger it?
- getWidth and getHeight are returning a zero
- Keytool alias does not exist
- How to delete a topic from Firebase Console? (FCM)
- Android:TextView height doesn’t change after shrinking the font size
- Placing ViewPager as a row in ListView
- How to change color of EditText handles?
- AlarmManager setExact with WakefulBroadcastReceiver sometimes not exact
- Android AlarmManager problem with setting & resetting an alarm
- How can I get the date & time from the network provider?
- Android Click on listItem checks wrong checkbox
- How to get RTSP Links Android
- Access android context in ndk application
- Stop MediaPlayer when an other app play music
- Error java.lang.RuntimeException: Stub! in Android with Fitnesse testing
- Android JSoup Example
- Fragment standard transition not animating
- Is possible set Expanded Notification as default in Big Text Notifications?
- Android :java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
- Is there another place to get a google-services.json?