本文整理汇总了Java中com.google.visualization.datasource.datatable.value.DateTimeValue类的典型用法代码示例。如果您正苦于以下问题:Java DateTimeValue类的具体用法?Java DateTimeValue怎么用?Java DateTimeValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateTimeValue类属于com.google.visualization.datasource.datatable.value包,在下文中一共展示了DateTimeValue类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataTable
import com.google.visualization.datasource.datatable.value.DateTimeValue; //导入依赖的package包/类
/**
* @param mValue
* mesured value
* @return gviz DataTable
* @throws DataSourceException
* data source exception
*/
private static DataTable getDataTable(InterpolatedValue mValue) throws DataSourceException {
MeasurementType mType = mValue.getMeasurementType();
DataTable data = new DataTable();
try {
data.addColumn(
new ColumnDescription("Date", ValueType.DATETIME, "Date & Time"));
data.addColumn(
new ColumnDescription(mType.getName(), ValueType.NUMBER, mType.toString()));
TableRow row = new TableRow();
XMLGregorianCalendar xgcal = DateConvert.convertDate(mValue.getStart());
row.addCell(new DateTimeValue(convertTimestamp(xgcal)));
row.addCell(mValue.getValue());
data.addRow(row);
}
catch (TypeMismatchException | DatatypeConfigurationException e) {
throw new DataSourceException(ReasonType.INTERNAL_ERROR, "Problem adding data to table"); // NOPMD
}
return data;
}
示例2: getDateFromValue
import com.google.visualization.datasource.datatable.value.DateTimeValue; //导入依赖的package包/类
/**
* Converts the given value to date. The value must be of type date or datetime.
*
* @param value The given value.
*
* @return Date object with the same value as the given value.
*/
private Date getDateFromValue(Value value) {
Calendar calendar;
if (value.getType() == ValueType.DATE) {
calendar = ((DateValue) value).getObjectToFormat();
} else { // datetime
calendar = ((DateTimeValue) value).getObjectToFormat();
}
return calendar.getTime();
}
示例3: parseDateTime
import com.google.visualization.datasource.datatable.value.DateTimeValue; //导入依赖的package包/类
/**
* Parses a string to a date time value.
*
* @param val The string to parse.
*
* @return A date time value based on the given string.
*
* @throws ParseException If val cannot be parsed into a date.
*/
private DateTimeValue parseDateTime(String val) throws ParseException {
Date date = ((SimpleDateFormat) uFormat).parse(val);
GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
gc.setTime(date);
return new DateTimeValue(gc);
}
示例4: evaluate
import com.google.visualization.datasource.datatable.value.DateTimeValue; //导入依赖的package包/类
/**
* Evaluates this scalar function. Returns a DateTime with the current time.
*
* @param values Ignored.
*
* @return A DateTime value with the current time.
*/
public Value evaluate(List<Value> values) {
return new DateTimeValue(new GregorianCalendar(
TimeZone.getTimeZone("GMT")));
}