java - Fastest String Format conversion -


i have following string: 20140420000001 want format to: 2014-04-20+00:00:01

what fastest possible way in java?

anything faster this?

string dt = "20140420000001"; system.out.println(dt.substring(0, 4)+"-"+dt.substring(4, 6)+"-"+dt.substring(6, 8)+"+"+dt.substring(8, 10)+":"+dt.substring(10, 12)+":"+dt.substring(12, 14)); 

    return new string(new char[] {             s.charat(0), s.charat(1), s.charat(2), s.charat(3),             '-', s.charat(4), s.charat(5),             '-', s.charat(6), s.charat(7),             '+', s.charat(8), s.charat(9),             ':', s.charat(10), s.charat(11),             ':', s.charat(12), s.charat(13)     }); 

not pretty, there hardly faster in pure java.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -