本文整理汇总了Java中org.apache.cassandra.serializers.TimestampSerializer类的典型用法代码示例。如果您正苦于以下问题:Java TimestampSerializer类的具体用法?Java TimestampSerializer怎么用?Java TimestampSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimestampSerializer类属于org.apache.cassandra.serializers包,在下文中一共展示了TimestampSerializer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testDateStringToTimestamp
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
@Test
public void testDateStringToTimestamp()
{
List<String> unparsedDates = new ArrayList<>();
for (String date: dates)
{
try
{
long millis = TimestampSerializer.dateStringToTimestamp(date);
}
catch (MarshalException e)
{
unparsedDates.add(date);
}
}
assertTrue("Unable to parse: " + unparsedDates, unparsedDates.isEmpty());
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:TimestampSerializerTest.java
示例2: fromString
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
return ByteBufferUtil.bytes(TimestampSerializer.dateStringToTimestamp(source));
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:DateType.java
示例3: fromStringCQL2
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
@Override
public ByteBuffer fromStringCQL2(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
ByteBuffer idBytes = null;
// ffffffff-ffff-ffff-ffff-ffffffffff
if (regexPattern.matcher(source).matches())
{
UUID uuid = null;
try
{
uuid = UUID.fromString(source);
idBytes = decompose(uuid);
}
catch (IllegalArgumentException e)
{
throw new MarshalException(String.format("unable to make UUID from '%s'", source), e);
}
if (uuid.version() != 1)
throw new MarshalException("TimeUUID supports only version 1 UUIDs");
}
else
{
idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(TimestampSerializer.dateStringToTimestamp(source)));
}
return idBytes;
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:34,代码来源:TimeUUIDType.java
示例4: dateStringToTimestamp
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
public static long dateStringToTimestamp(String source) throws MarshalException
{
long millis;
if (source.toLowerCase().equals("now"))
{
millis = System.currentTimeMillis();
}
// Milliseconds since epoch?
else if (source.matches("^\\d+$"))
{
try
{
millis = Long.parseLong(source);
}
catch (NumberFormatException e)
{
throw new MarshalException(String.format("unable to make long (for date) from: '%s'", source), e);
}
}
// Last chance, attempt to parse as date-time string
else
{
try
{
millis = DateUtils.parseDateStrictly(source, TimestampSerializer.iso8601Patterns).getTime();
}
catch (ParseException e1)
{
throw new MarshalException(String.format("unable to coerce '%s' to a formatted date (long)", source), e1);
}
}
return millis;
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:36,代码来源:DateType.java
示例5: dateStringToTimestamp
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
public static long dateStringToTimestamp(String source) throws MarshalException
{
long millis;
if (source.toLowerCase().equals("now"))
{
millis = System.currentTimeMillis();
}
// Milliseconds since epoch?
else if (timestampPattern.matcher(source).matches())
{
try
{
millis = Long.parseLong(source);
}
catch (NumberFormatException e)
{
throw new MarshalException(String.format("unable to make long (for date) from: '%s'", source), e);
}
}
// Last chance, attempt to parse as date-time string
else
{
try
{
millis = DateUtils.parseDateStrictly(source, TimestampSerializer.iso8601Patterns).getTime();
}
catch (ParseException e1)
{
throw new MarshalException(String.format("unable to coerce '%s' to a formatted date (long)", source), e1);
}
}
return millis;
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:36,代码来源:TimestampType.java
示例6: dateStringToTimestamp
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
public static long dateStringToTimestamp(String source) throws MarshalException
{
long millis;
if (source.toLowerCase().equals("now"))
{
millis = System.currentTimeMillis();
}
// Milliseconds since epoch?
else if (source.matches("^-?\\d+$"))
{
try
{
millis = Long.parseLong(source);
}
catch (NumberFormatException e)
{
throw new MarshalException(String.format("unable to make long (for date) from: '%s'", source), e);
}
}
// Last chance, attempt to parse as date-time string
else
{
try
{
millis = DateUtils.parseDateStrictly(source, TimestampSerializer.iso8601Patterns).getTime();
}
catch (ParseException e1)
{
throw new MarshalException(String.format("unable to coerce '%s' to a formatted date (long)", source), e1);
}
}
return millis;
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:36,代码来源:DateType.java
示例7: toJSONString
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
@Override
public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
{
return '"' + TimestampSerializer.getJsonDateFormatter().format(TimestampSerializer.instance.deserialize(buffer)) + '"';
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:6,代码来源:DateType.java
示例8: getSerializer
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
public TypeSerializer<Date> getSerializer()
{
return TimestampSerializer.instance;
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:5,代码来源:DateType.java
示例9: toJSONString
import org.apache.cassandra.serializers.TimestampSerializer; //导入依赖的package包/类
@Override
public String toJSONString(ByteBuffer buffer, int protocolVersion)
{
return '"' + TimestampSerializer.getJsonDateFormatter().format(TimestampSerializer.instance.deserialize(buffer)) + '"';
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:6,代码来源:DateType.java
注:本文中的org.apache.cassandra.serializers.TimestampSerializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论