java - empty array, split method -


this question has answer here:

my problem array ms[ ] doesn't values when split( ); why happening ?

public class test {      public static void main(string[] args) {         date date = new date();         simpledateformat ft = new simpledateformat("yyyy.mm.dd.hh.mm.ss.");    //change format                   string msgtime = ft.format(date);         system.out.println(msgtime);          string ms[] = msgtime.split(".");         system.out.println(ms.length);     } }  

the problem split() function takes regular expression argument, not simple string. , "." regular expression means "any symbol". need escape it.

string ms[] = msgtime.split("\\.");


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -