You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 4 Next »
Assigning a non-string value to a string variable implicitly converts the value to string.
string
int i = 12; string s = i; //int to string decimal d = 12.34; string s = d; //decimal to string
To convert from string to another primitive, use the fromString(s) BIFs available on the corresponding data type namespace.
fromString(s)
string s = "12"; int i = Integer:fromString(s);
decimal d = Decimal:fromString("12.34");
uuid id = Uuid:fromString(user._id);
date d = Date:fromString("2017-01-02");
For converting from string to datetime, use Date:fromTimeString(s):
datetime
Date:fromTimeString(s)
datetime dt = Date:fromTimeString("2017-1-20 08:45:12 GMT");
0 Comments