Formatted Output

Former Member
Former Member
hi there,

i have a problem with the formatted output for a given time on my whatchface:

view.setText(Lang.format("$1$:$2$:$3$", [hh.format("%.2d"), mm.format("%.2d"), ss.format("%.2d")]));

for example hh=12; mm=2; ss=5;

it works fine on the emulator (12:02:05 is correctly shown on screen), but it doesn't work "in real" at my fenix3 device (12:2:5 ist shown there!).

any idea what's wrong here?

thanks in advance.

stefan
  • Travis - I missed it at first too. Look at the code. He's not using format() - he's passing a format string to toString().

    But shouldn't toString() throw an error with the parameter count miss-match?
  • Oh, wait, you're using toString().


    Genius! i feel so stupid. format did the trick.

    thank you to both of you, jim and travis. BTW, passing the format string as a parameter does not trigger an error. i have used tenths of time format in my other app. i should have looked there....
  • But shouldn't toString() throw an error with the parameter count miss-match?


    Yes, it certainly should. We should create a test case and post it to the bug reports forum.

    Apparently I was writing that test case when you posted, and failed to notice you had found the flaw. Nice catch...
  • Hey Travis, I'll wait a few minutes and if you haven't done the bug report, I'll do it - Just so we're both not doing posts at the same time! :)