Thursday, September 29, 2011

Insert a new line for Textarea - JavaScript

function go() {
    var pre=document.createElement('pre');
    var text = document.createTextNode("line1\u000A\u000Dline2");
    pre.appendChild(text); document.body.appendChild(pre);
}

Labels:

Tuesday, September 27, 2011

CSS Background Color - Windows Blue

CSS Background: "background-color:#b0c4de;"

'via Blog this'

Add leading zeroes in Java

Add leading zeroes in Java - Stack Overflow: "Since Java 1.5 you can use the String.format method. For example, to do the same thing as your example:

    String format = String.format("%%0%dd", digits);
    String result = String.format(format, num);
    return result;
In this case, you're creating the format string using the width specified in digits, then applying it directly to the number. The format for this example is converted as follows:

%% --> %
0 --> 0
%d -->
d --> d
So if digits is equal to 5, the format string becomes "%05d" which specifies an integer with a width of 5 printing leading zeroes. See the java docs for String.format for more information on the conversion specifiers"

'via Blog this'