本文整理匯總了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")));
}