Hi I have the following xml file
<?xml version="1.0" encoding="UTF-8"?>
<share>
<item>
<name>Ericsson B</name>
<currentRate>80.69</currentRate>
<changeToday>-0.51</changeToday>
<changeTodayPercent>-0.52</changeTodayPercent>
<timeUpdated>2012,12,06,18,00,00</timeUpdated>
</item>
</share>
And I can read every variable and put them in an arraylist, all EXCEPT the “timeUpdated” variable that I can’t manage to convert from string on the form “2012,12,06,18,00,00” to put into a new gregorian calendar like below
GregorianCalendar updated = new GregorianCalendar(2012,12,06,16,30,55);
So my question how do I convert a String on the form “2012,12,06,16,30,55” to be able to put into
GregorianCalendar updated = new GregorianCalendar(“My converted calendar string”);
If you wonder here is my xmlparser
public AllSharesOnStockMarket(){
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_ITEM);
for (int i = 0; i < nl.getLength(); i++) {
Element e = (Element) nl.item(i);
System.out.println(e);
System.out.println("hejsan");
System.out.println(parser.getValue(e, KEY_NAME));
allShareHoldingsOnStockMarket.get(i).setName(parser.getValue(e, KEY_NAME));
tempDouble = Double.parseDouble(parser.getValue(e, KEY_CURRENTRATE));
allShareHoldingsOnStockMarket.get(i).setCurrentRate(tempDouble);
tempDouble = Double.parseDouble(parser.getValue(e, KEY_CHANGETODAY));
allShareHoldingsOnStockMarket.get(i).setCurrentRate(tempDouble);
tempDouble = Double.parseDouble(parser.getValue(e, KEY_CHANGETODAYPERCENT));
allShareHoldingsOnStockMarket.get(i).setChangeTodayPercent(tempDouble);
String dateToConvert = parser.getValue(e, KEY_TIMEUPDATED);//Need to convert this into a date so I can put into
allShareHoldingsOnStockMarket.get(i).setTimeUpdated("My Converted Date String That is the converted dateToConvert String");
}
}
Try as