Hi
Try the below, you can use ValueType.DATETIME or ValueType.DATE
1)Import the below
import com.google.visualization.datasource.datatable.value.DateTimeValue;
import com.google.visualization.datasource.datatable.value.ValueType;
2)define the arraylist to define the column description list
ArrayList cd = new ArrayList();
cd.add(new ColumnDescription("start date", ValueType.DATETIME, "Start
Date"));
DateTimeValue dt = new DateTimeValue(getDate(eachDate, "year"),
getDate(eachDate, "month"), getDate(eachDate, "day"), getDate(eachDate,
"hour"), getDate(eachDate, "min"), getDate(eachDate, "sec"), 0);
getDate is a method optional you could follow your own way of passing the
constructor values of DateTimeValue
//////////
private int getDate(String dates, String token) {
//01-JUL-2009 23:20:32
int returns = 0;
if (token.equalsIgnoreCase("year")) {
returns = Integer.parseInt(dates.substring(7, 11));
} else if (token.equalsIgnoreCase("month")) {
String asd = dates.substring(3, 6);
returns = Integer.parseInt((String) datemapping.get(asd));
} else if (token.equalsIgnoreCase("day")) {
returns = Integer.parseInt(dates.substring(0, 2));
} else if (token.equalsIgnoreCase("hour")) {
returns = Integer.parseInt(dates.substring(12, 14));
} else if (token.equalsIgnoreCase("min")) {
returns = Integer.parseInt(dates.substring(15, 17));
} else if (token.equalsIgnoreCase("sec")) {
returns = Integer.parseInt(dates.substring(18, 20));
}
return returns;
}
////////
ThanksSuresh
On Fri, Oct 16, 2009 at 6:33 AM, yozzy <[email protected]> wrote:
>
> Hi,
> I've tried to create an motionChart with date values.
> I've a servlet that create the DataTable with date values. I've tried
> this:
>
> import com.ibm.icu.util.Calendar;
> import com.ibm.icu.util.GregorianCalendar;
> import com.ibm.icu.util.TimeZone;
>
> //Creation of calendar for date type
> GregorianCalendar calendar = new GregorianCalendar(2009, 2, 15);
> calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
> System.out.println("calendar "+calendar);
> Value v = new DateValue(calendar);
>
> ...
>
> //Adding values to data adding date value
> data.addRowFromValues("Desc", v, 1000, 300, "Ecomm")
>
> This didn't worked and gave me a typemismatch error...then i find on
> this blog
> http://blake.tsuhakofamily.com/2009/07/google-visualization-api-java-servlets-date/
> that the only solution to this problem is to create an add every
> single cell...with this code:
>
> TableRow tr = new TableRow();
> tr.addCell("test1");
> tr.addCell("http://www.google.com");
> tr.addCell(2000);
> tr.addCell(false);
> DateValue d = new DateValue(2009, 11, 21);
> tr.addCell(d);
> data.addRow(tr);
>
> I think that the method addRowFromValues doesn't work for DATE type.
> I'm wrong?
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---