当前位置: 首页>>代码示例>>Java>>正文


Java DateConverter类代码示例

本文整理汇总了Java中mil.nga.geopackage.db.DateConverter的典型用法代码示例。如果您正苦于以下问题:Java DateConverter类的具体用法?Java DateConverter怎么用?Java DateConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateConverter类属于mil.nga.geopackage.db包,在下文中一共展示了DateConverter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDefaultString

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object parseDefaultString(FieldType fieldType, String defaultStr) {
	Object defaultValue = null;
	if (DateConverter.DATETIME_FORMAT.equals(defaultStr)) {
		defaultValue = javaToSqlArg(null, new Date());
	}
	return defaultValue;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:12,代码来源:DatePersister.java

示例2: getValue

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Get the value from the cursor from the provided column
 *
 * @param result
 * @param index
 * @param dataType
 * @return value
 */
public static Object getValue(UserCoreResult<?, ?, ?> result, int index,
		GeoPackageDataType dataType) {

	Object value = null;

	int type = result.getType(index);

	switch (type) {

	case FIELD_TYPE_INTEGER:
		value = getIntegerValue(result, index, dataType);
		break;

	case FIELD_TYPE_FLOAT:
		value = getFloatValue(result, index, dataType);
		break;

	case FIELD_TYPE_STRING:
		String stringValue = result.getString(index);

		if (dataType == GeoPackageDataType.DATE
				|| dataType == GeoPackageDataType.DATETIME) {
			DateConverter converter = DateConverter.converter(dataType);
			value = converter.dateValue(stringValue);
		} else {
			value = stringValue;
		}
		break;

	case FIELD_TYPE_BLOB:
		value = result.getBlob(index);
		break;

	case FIELD_TYPE_NULL:
		// leave value as null
	}

	return value;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:48,代码来源:UserCoreResultUtils.java

示例3: columnToContentValue

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Map the column to the content values
 *
 * @param contentValues
 * @param column
 * @param value
 */
protected void columnToContentValue(ContentValues contentValues,
                                    TColumn column, Object value) {

    String columnName = column.getName();

    if (value instanceof Number) {
        if (value instanceof Byte) {
            validateValue(column, value, Byte.class, Short.class,
                    Integer.class, Long.class);
            contentValues.put(columnName, (Byte) value);
        } else if (value instanceof Short) {
            validateValue(column, value, Short.class, Integer.class,
                    Long.class);
            contentValues.put(columnName, (Short) value);
        } else if (value instanceof Integer) {
            validateValue(column, value, Integer.class, Long.class);
            contentValues.put(columnName, (Integer) value);
        } else if (value instanceof Long) {
            validateValue(column, value, Long.class, Double.class);
            contentValues.put(columnName, (Long) value);
        } else if (value instanceof Float) {
            validateValue(column, value, Float.class);
            contentValues.put(columnName, (Float) value);
        } else if (value instanceof Double) {
            validateValue(column, value, Double.class);
            contentValues.put(columnName, (Double) value);
        } else {
            throw new GeoPackageException("Unsupported Number type: "
                    + value.getClass().getSimpleName());
        }
    } else if (value instanceof String) {
        validateValue(column, value, String.class);
        String stringValue = (String) value;
        if (column.getMax() != null
                && stringValue.length() > column.getMax()) {
            throw new GeoPackageException(
                    "String is larger than the column max. Size: "
                            + stringValue.length() + ", Max: "
                            + column.getMax() + ", Column: " + columnName);
        }
        contentValues.put(columnName, stringValue);
    } else if (value instanceof byte[]) {
        validateValue(column, value, byte[].class);
        byte[] byteValue = (byte[]) value;
        if (column.getMax() != null && byteValue.length > column.getMax()) {
            throw new GeoPackageException(
                    "Byte array is larger than the column max. Size: "
                            + byteValue.length + ", Max: "
                            + column.getMax() + ", Column: " + columnName);
        }
        contentValues.put(columnName, byteValue);
    } else if (value instanceof Boolean) {
        validateValue(column, value, Boolean.class);
        Boolean booleanValue = (Boolean) value;
        short shortBoolean = booleanValue ? (short) 1 : (short) 0;
        contentValues.put(columnName, shortBoolean);
    } else if (value instanceof Date) {
        validateValue(column, value, Date.class, String.class);
        Date dateValue = (Date) value;
        DateConverter converter = DateConverter.converter(column
                .getDataType());
        String dateString = converter.stringValue(dateValue);
        contentValues.put(columnName, dateString);
    } else {
        throw new GeoPackageException(
                "Unsupported update column value. column: " + columnName
                        + ", value: " + value);
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:77,代码来源:UserRow.java

示例4: validateFeatureRow

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Validate a feature row
 * 
 * @param columns
 * @param featureRow
 */
private static void validateFeatureRow(String[] columns,
		FeatureRow featureRow) {
	TestCase.assertEquals(columns.length, featureRow.columnCount());

	for (int i = 0; i < featureRow.columnCount(); i++) {
		FeatureColumn column = featureRow.getTable().getColumns().get(i);
		GeoPackageDataType dataType = column.getDataType();
		TestCase.assertEquals(i, column.getIndex());
		TestCase.assertEquals(columns[i], featureRow.getColumnName(i));
		TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i]));
		int rowType = featureRow.getRowColumnType(i);
		Object value = featureRow.getValue(i);

		switch (rowType) {

		case Cursor.FIELD_TYPE_INTEGER:
			TestUtils.validateIntegerValue(value, column.getDataType());
			break;

		case Cursor.FIELD_TYPE_FLOAT:
			TestUtils.validateFloatValue(value, column.getDataType());
			break;

		case Cursor.FIELD_TYPE_STRING:
			if(dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME){
				TestCase.assertTrue(value instanceof Date);
				Date date = (Date) value;
				DateConverter converter = DateConverter.converter(dataType);
				String dateString = converter.stringValue(date);
				TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime());
			}else{
				TestCase.assertTrue(value instanceof String);
			}
			break;

		case Cursor.FIELD_TYPE_BLOB:
			if (featureRow.getGeometryColumnIndex() == i) {
				TestCase.assertTrue(value instanceof GeoPackageGeometryData);
			} else {
				TestCase.assertTrue(value instanceof byte[]);
			}
			break;

		case Cursor.FIELD_TYPE_NULL:
			TestCase.assertNull(value);
			break;

		}
	}
	
	TestCase.assertTrue(featureRow.getId() >= 0);
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:59,代码来源:FeatureUtils.java

示例5: validateAttributesRow

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Validate an attributes row
 * 
 * @param columns
 * @param attributesRow
 */
private static void validateAttributesRow(String[] columns,
		AttributesRow attributesRow) {
	TestCase.assertEquals(columns.length, attributesRow.columnCount());

	for (int i = 0; i < attributesRow.columnCount(); i++) {
		AttributesColumn column = attributesRow.getTable().getColumns()
				.get(i);
           GeoPackageDataType dataType = column.getDataType();
		TestCase.assertEquals(i, column.getIndex());
		TestCase.assertEquals(columns[i], attributesRow.getColumnName(i));
		TestCase.assertEquals(i, attributesRow.getColumnIndex(columns[i]));
		int rowType = attributesRow.getRowColumnType(i);
		Object value = attributesRow.getValue(i);

		switch (rowType) {

		case UserCoreResultUtils.FIELD_TYPE_INTEGER:
			TestUtils.validateIntegerValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_FLOAT:
			TestUtils.validateFloatValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_STRING:
               if(dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME){
                   TestCase.assertTrue(value instanceof Date);
                   Date date = (Date) value;
                   DateConverter converter = DateConverter.converter(dataType);
                   String dateString = converter.stringValue(date);
                   TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime());
               }else{
                   TestCase.assertTrue(value instanceof String);
               }
			break;

		case UserCoreResultUtils.FIELD_TYPE_BLOB:
			TestCase.assertTrue(value instanceof byte[]);
			break;

		case UserCoreResultUtils.FIELD_TYPE_NULL:
			TestCase.assertNull(value);
			break;

		}
	}

	TestCase.assertTrue(attributesRow.getId() >= 0);
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:56,代码来源:AttributesUtils.java

示例6: columnToContentValue

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Map the column to the content values
 * 
 * @param contentValues
 * @param column
 * @param value
 */
protected void columnToContentValue(ContentValues contentValues,
		TColumn column, Object value) {

	String columnName = column.getName();

	if (value instanceof Number) {
		if (value instanceof Byte) {
			validateValue(column, value, Byte.class, Short.class,
					Integer.class, Long.class);
			contentValues.put(columnName, (Byte) value);
		} else if (value instanceof Short) {
			validateValue(column, value, Short.class, Integer.class,
					Long.class);
			contentValues.put(columnName, (Short) value);
		} else if (value instanceof Integer) {
			validateValue(column, value, Integer.class, Long.class);
			contentValues.put(columnName, (Integer) value);
		} else if (value instanceof Long) {
			validateValue(column, value, Long.class, Double.class);
			contentValues.put(columnName, (Long) value);
		} else if (value instanceof Float) {
			validateValue(column, value, Float.class);
			contentValues.put(columnName, (Float) value);
		} else if (value instanceof Double) {
			validateValue(column, value, Double.class);
			contentValues.put(columnName, (Double) value);
		} else {
			throw new GeoPackageException("Unsupported Number type: "
					+ value.getClass().getSimpleName());
		}
	} else if (value instanceof String) {
		validateValue(column, value, String.class);
		String stringValue = (String) value;
		if (column.getMax() != null
				&& stringValue.length() > column.getMax()) {
			throw new GeoPackageException(
					"String is larger than the column max. Size: "
							+ stringValue.length() + ", Max: "
							+ column.getMax() + ", Column: " + columnName);
		}
		contentValues.put(columnName, stringValue);
	} else if (value instanceof byte[]) {
		validateValue(column, value, byte[].class);
		byte[] byteValue = (byte[]) value;
		if (column.getMax() != null && byteValue.length > column.getMax()) {
			throw new GeoPackageException(
					"Byte array is larger than the column max. Size: "
							+ byteValue.length + ", Max: "
							+ column.getMax() + ", Column: " + columnName);
		}
		contentValues.put(columnName, byteValue);
	} else if (value instanceof Boolean) {
		validateValue(column, value, Boolean.class);
		Boolean booleanValue = (Boolean) value;
		short shortBoolean = booleanValue ? (short) 1 : (short) 0;
		contentValues.put(columnName, shortBoolean);
	} else if (value instanceof Date) {
		validateValue(column, value, Date.class, String.class);
		Date dateValue = (Date) value;
		DateConverter converter = DateConverter.converter(column
				.getDataType());
		String dateString = converter.stringValue(dateValue);
		contentValues.put(columnName, dateString);
	} else {
		throw new GeoPackageException(
				"Unsupported update column value. column: " + columnName
						+ ", value: " + value);
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:77,代码来源:UserRow.java

示例7: validateFeatureRow

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Validate a feature row
 * 
 * @param columns
 * @param featureRow
 */
private static void validateFeatureRow(String[] columns,
		FeatureRow featureRow) {
	TestCase.assertEquals(columns.length, featureRow.columnCount());

	for (int i = 0; i < featureRow.columnCount(); i++) {
		FeatureColumn column = featureRow.getTable().getColumns().get(i);
		GeoPackageDataType dataType = column.getDataType();
		TestCase.assertEquals(i, column.getIndex());
		TestCase.assertEquals(columns[i], featureRow.getColumnName(i));
		TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i]));
		int rowType = featureRow.getRowColumnType(i);
		Object value = featureRow.getValue(i);

		switch (rowType) {

		case UserCoreResultUtils.FIELD_TYPE_INTEGER:
			TestUtils.validateIntegerValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_FLOAT:
			TestUtils.validateFloatValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_STRING:
			if(dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME){
				TestCase.assertTrue(value instanceof Date);
				Date date = (Date) value;
				DateConverter converter = DateConverter.converter(dataType);
				String dateString = converter.stringValue(date);
				TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime());
			}else{
				TestCase.assertTrue(value instanceof String);
			}
			break;

		case UserCoreResultUtils.FIELD_TYPE_BLOB:
			if (featureRow.getGeometryColumnIndex() == i) {
				TestCase.assertTrue(value instanceof GeoPackageGeometryData);
			} else {
				TestCase.assertTrue(value instanceof byte[]);
			}
			break;

		case UserCoreResultUtils.FIELD_TYPE_NULL:
			TestCase.assertNull(value);
			break;

		}
	}

	TestCase.assertTrue(featureRow.getId() >= 0);
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:59,代码来源:FeatureUtils.java

示例8: validateAttributesRow

import mil.nga.geopackage.db.DateConverter; //导入依赖的package包/类
/**
 * Validate an attributes row
 * 
 * @param columns
 * @param attributesRow
 */
private static void validateAttributesRow(String[] columns,
		AttributesRow attributesRow) {
	TestCase.assertEquals(columns.length, attributesRow.columnCount());

	for (int i = 0; i < attributesRow.columnCount(); i++) {
		AttributesColumn column = attributesRow.getTable().getColumns()
				.get(i);
		GeoPackageDataType dataType = column.getDataType();
		TestCase.assertEquals(i, column.getIndex());
		TestCase.assertEquals(columns[i], attributesRow.getColumnName(i));
		TestCase.assertEquals(i, attributesRow.getColumnIndex(columns[i]));
		int rowType = attributesRow.getRowColumnType(i);
		Object value = attributesRow.getValue(i);

		switch (rowType) {

		case UserCoreResultUtils.FIELD_TYPE_INTEGER:
			TestUtils.validateIntegerValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_FLOAT:
			TestUtils.validateFloatValue(value, column.getDataType());
			break;

		case UserCoreResultUtils.FIELD_TYPE_STRING:
			if (dataType == GeoPackageDataType.DATE
					|| dataType == GeoPackageDataType.DATETIME) {
				TestCase.assertTrue(value instanceof Date);
				Date date = (Date) value;
				DateConverter converter = DateConverter.converter(dataType);
				String dateString = converter.stringValue(date);
				TestCase.assertEquals(date.getTime(),
						converter.dateValue(dateString).getTime());
			} else {
				TestCase.assertTrue(value instanceof String);
			}
			break;

		case UserCoreResultUtils.FIELD_TYPE_BLOB:
			TestCase.assertTrue(value instanceof byte[]);
			break;

		case UserCoreResultUtils.FIELD_TYPE_NULL:
			TestCase.assertNull(value);
			break;

		}
	}

	TestCase.assertTrue(attributesRow.getId() >= 0);
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:58,代码来源:AttributesUtils.java


注:本文中的mil.nga.geopackage.db.DateConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。