java - how to write date using tokenizer? -


the following code here returns date in form "day, date, month, year".
date entered in return saturday 28 dec 2013. however, want tokenize , print 4 parts out on 4 separate lines, starting month, date, year, day. what's best way this?

import java.text.simpledateformat; import java.util.date;  class day{      public static void main( string[] args ){      simpledateformat newdateformat = new simpledateformat("dd/mm/yyyy");      try {         date mydate = newdateformat.parse("28/12/2013");         newdateformat.applypattern("eeee dd mmm yyyy");         string isdate = newdateformat.format(mydate);         system.out.println(isdate);     } catch (exception e) {         system.out.println("error. date in wrong format.");     }     } } 

use split() method :

 string []myformat=isdate.split(" ");  system.out.println(myformat[2]);  system.out.println(myformat[1]);  system.out.println(myformat[3]);  system.out.println(myformat[0]); 

use order whatever order want.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -