How to show date and time in google chart using google chart data source

225 Views Asked by At

I have a REST service that send json object to google chart to draw data in jsp. In REST service side i use google DataTable API to generate google support josn obj.The problem is that i tried to pass my date time value into data table but in google chart it doesn't show anything.I tried with different ways but couldn't find a way.If you know how to overcome that problem Please let me know.

    final DataTable data = new DataTable();
    ArrayList<ColumnDescription> cl = new ArrayList<ColumnDescription>();
    cl.add(new ColumnDescription("Time Stamp", ValueType.DATETIME, "TimeStamp"));
    data.addColumns(cl);
    data.addRowFromValues("Date("+tr.getTimestamp()+")");

    JsonNode root = null;
    String json = JsonRenderer.renderDataTable(data, true, false).toString();

    try{
        JsonParser parser = new JsonFactory().createJsonParser(json)
            .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES)
            .enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
             root = new ObjectMapper().readTree(parser);
        }catch(Exception e){
           System.out.println(e.toString());
        }
return root.toString();

tr.getTimestamp() fetch date values from DB.

DB Date value,
12/5/2014 10:48:25 AM
0

There are 0 best solutions below