如何知道Javascript中输入的长度
alert("Size: "+document.getElementById('champ').length)
Run Code Online (Sandbox Code Playgroud)
不工作未定义
我有一个整数值,我想在十六进制转换它.
我这样做:
private short getCouleur(Integer couleur, HSSFWorkbook classeur) {
if (null == couleur) {
return WHITE.index;
} else {
HSSFPalette palette = classeur.getCustomPalette();
String hexa = Integer.toHexString(couleur);
byte r = Integer.valueOf(hexa.substring(0, 2), 16).byteValue();
byte g = Integer.valueOf(hexa.substring(2, 4), 16).byteValue();
byte b = Integer.valueOf(hexa.substring(4, 6), 16).byteValue();
palette.setColorAtIndex((short) 65, r, g, b);
return (short) 65;
}
}
Run Code Online (Sandbox Code Playgroud)
在输出中我有这个:
couleur:65331
六:FF33
hexa.substring(0,2):FF
hexa.substring(2,4):33
hexa.substring(4,6):
r:-1
g:51
b:错误消息
错误消息:字符串索引超出范围:6
谢谢.
String[] parts = pptValue.split("{");
Run Code Online (Sandbox Code Playgroud)
在我的pptValue
:
pptValue = EnvWDI{env}{client}
Run Code Online (Sandbox Code Playgroud)
我的错误:
Caught: java.util.regex.PatternSyntaxException: Illegal repetition
{
java.util.regex.PatternSyntaxException: Illegal repetition
{
at java_lang_String$split.call(Unknown Source)
Run Code Online (Sandbox Code Playgroud) 我有一个表示日期的String变量
console.log(goDate); --> "23/12/2014"
Run Code Online (Sandbox Code Playgroud)
我怎么能像这样改变这个变量..?:
console.log(goDate); --> "2014-12-23".
Run Code Online (Sandbox Code Playgroud)