Oh I see now. You can't concatenate using plus sign (+) anymore. Since the text field itself is already concatenation box.
The reason why your original script evaluated to the one you have is because the concat happen before the dateformat.
{"time: " +
getDate(),dateformat,HH:mm}
will be evaluated to
{"time: "
+ 1527676279092,dateformat,HH:mm}
continued, it is string concatenation
{
"time: 1527676279092",dateformat,HH:mm}
since the whole
"time: 1527676279092" is a string, not a valid date, nothing will show up when parsed using dateformat, thus retain its original form.
"time: 1527676279092"
You should put your time as here.
time: {getDate(),dateformat,HH:mm}
or if you need the braces, you need double it, each part get its own pair
{"time: "}{getDate(),dateformat,HH:mm}
"time: " can be replaced with if() statement if you want
{if(1==2) true else false} {getDate(),dateformat,HH:mm}
So the braces only surround the one need to be evaluated before showing. "time: " is not needed to be evaluated, need to put outside. All of the pattern format (numberformat, dateformat, listformat etc), may not have concatenation at the beginning part inside the braces, as it will concatenate first before parsed using the pattern format. The concatenation must happen outside of the braces. And you can't concatenate braces inside concat() function when using it in text field,
Code: Select all
{concat("time: ", "{getDate(),dateformat,HH:mm}"} // is wrong in text field, need nested braces
because you will need nested braces, which is not supported. This happen in all text fields which support variable using curly braces, including : Widget Text, Message Dialog, Notification on Screen (toast message), and a lot of other elements which support variable through curly braces.
However, In scripting box : script, expression, control UI and extra field (Start activity, service, broadcast etc), you can use the pattern format inside concat() (and any other function which require argument), as you don't need braces to surround the concat() (or other function).
Code: Select all
text = concat("time: ", "{getDate(),dateformat,HH:mm}") // is correct if used in script action, only single pair of braces