xLang的类型转换今天学习了xLang的类型转换

1、想要将Int转换为String时,请使用string.format(‘%d ‘,123 )

例如

int a=2; 字符串b=’ ‘; b=string.format(‘%d ‘,a ); 这里的%d部分可以替换为其他部分(

%d整数%f浮点数。 默认情况下,保留6位小数%s字符串%c个字符%。 [n]f保留n位小数%e,从而格式浮点数是科学计数法%[n]d格式整数,n保留数位整数,如format(‘d ‘ )。 1 ),’ 01’%g是格式化浮点数%s,格式化字符串%X是十六进制格式%p是用于格式化指针的String.formatDate是日期http://www.Sina.com/http://www.Sina.com

/***@brief格式日期字符串*@param fmt格式%Y年%m月%d日%H时%m分%S秒可用格式如下: * a : abbreviated weekdayname * a : fullnameoftheweekday b : abbreviated monthname * b : fullnameofmonth * c : le ‘ ‘ d 3360 dayo fthe month (01-3360 h : houroftheday (00-23 ) I : houroftheday (01-12 ) j : dayo fthe year (001-366 ) m 3360minute(00-59 ) p :本地’ sversionofamorpm ) s:seconds(00-59 ) u : weeknumberoftheyear (00-53 ) ) ) ) w : weekday (Sunday=0to Saturday=6) w : weeknumberoftheyear (00-53 ) ) ) ) 652 withmondayasthefeyear x :本地’ stimerepresentation * y : two-digityearrepresentation (00-99 ) y : four-digityearrepresentation * z :

2、如果想将字符串转换为Int,请选择parseInt (

例如

字符串a=’ 1234 ‘; 字符串b=’ 7890 ‘; string c=a b; int d=c.parseInt (;