How to Update the Terminal's Time Setting: Difference between revisions

From wizarPOS
No edit summary
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/settings-menu/update-terminal-time}}")
Tag: Replaced
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Use the android system clock method to change the system time.
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/settings-menu/update-terminal-time}}
== Permissions ==
  android.permission.CLOUDPOS_SETTIME
The app declares the permission in the manifest.
 
== Download ==
follows is the snippet code:
<syntaxhighlight lang="java">
public static void setDateTime(int year, int month, int day, int hour, int minute) throws IOException, InterruptedException {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month-1);
        c.set(Calendar.DAY_OF_MONTH, day);
        c.set(Calendar.HOUR_OF_DAY, hour);
        c.set(Calendar.MINUTE, minute);
       
        long when = c.getTimeInMillis();
        if (when / 1000 < Integer.MAX_VALUE) {
            SystemClock.setCurrentTimeMillis(when);
        }
        long now = Calendar.getInstance().getTimeInMillis();
        //Log.d(TAG, "set tm="+when + ", now tm="+now);
        if(now - when > 1000)
            throw new IOException("failed to set Date.");
       
    }
</syntaxhighlight>
Please download the [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/SetTimeDemo.zip whold project demo]

Latest revision as of 08:53, 7 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/faq/settings-menu/update-terminal-time

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!