I have a text file display the following:
Date Opening Closing
6-Mar-2006 11022.47 10958.59
9-Jun-2006 11005.66 10972.28
7-Dec-2006 10957.31 10980.69
28-Feb-2006 11096.75 10993.41
8-Mar-2006 10977.08 11005.74
How can I read in this file and convert all the months in String to month in int display. "Mar"
to 3
, "Jun"
to 6
. etc
My code so far:
Scanner in= new Scanner(System.in);
int N=in.nextInt();
in.close();
Scanner input=new Scanner(new File("file.txt"));
while (input.hasNextLine()){
String line=input.nextLine();
String[] fields=line.split(" ");
String date=fields[0];
String[] datefields=date.split("-");
String month=datefields[1];
*******************************************************
This is where I want to do the conversion.
*******************************************************
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…