本文整理匯總了Java中com.fasterxml.jackson.databind.util.ISO8601Utils類的典型用法代碼示例。如果您正苦於以下問題:Java ISO8601Utils類的具體用法?Java ISO8601Utils怎麽用?Java ISO8601Utils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ISO8601Utils類屬於com.fasterxml.jackson.databind.util包,在下文中一共展示了ISO8601Utils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetValueCookiesDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Test
public void testGetValueCookiesDate() throws Exception {
Date date = new Date();
String strDate = ISO8601Utils.format(date);
Cookie[] cookies = new Cookie[] {new Cookie("c1", strDate)};
new Expectations() {
{
request.getCookies();
result = cookies;
}
};
CookieProcessor processor = createProcessor("c1", Date.class);
Object value = processor.getValue(request);
Assert.assertEquals(strDate, ISO8601Utils.format((Date) value));
}
示例2: parse
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Override
public Date parse(String source, ParsePosition pos)
{
// index must be set to other than 0, I would swear this requirement is
// not there in some version of jdk 6.
String toParse = source;
if( !toParse.toUpperCase().contains("T") )
{
toParse = toParse + "T00:00:00Z";
}
try {
return ISO8601Utils.parse(toParse, pos);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
示例3: assertDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
public void assertDate(JsonNode dateNode, Object time)
{
Date parsed = ISO8601Utils.parse(dateNode.textValue());
long timeMillis;
if( time instanceof String )
{
timeMillis = ISO8601Utils.parse((String) time).getTime();
}
else if( time instanceof Date )
{
timeMillis = ((Date) time).getTime();
}
else
{
timeMillis = ((Number) time).longValue();
}
if( timeMillis / 1000 != parsed.getTime() / 1000 )
{
Assert.assertEquals(dateNode.textValue(),
ISO8601Utils.format(new Date(timeMillis), true, TimeZone.getTimeZone("America/Chicago")));
}
}
示例4: createResponse
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public MockResponse createResponse(MockRequest request) {
Optional<String> targetKey = getObjectKey(request);
Optional<Bucket> targetBucket = getBucket(request);
Optional<S3Object> source = getSourceFromHeader(request);
if (request.utils().areAllPresent(targetKey, targetBucket, source)) {
S3Object copy = SerializationUtils.clone(source.get());
copy.setKey(targetKey.get());
targetBucket.get().getObjects().add(copy);
}
return new MockResponse(
successBody("CopyObject", "<LastModified>" + ISO8601Utils.format(new Date())
+ "</LastModified>\n" + " <ETag>" + UUID.randomUUID().toString() + "</ETag>"));
}
示例5: parse
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Override
public Date parse(String source, ParsePosition pos) {
// index must be set to other than 0, I would swear this requirement is not there in
// some version of jdk 6.
//pos.setIndex(source.length());
try {
return ISO8601Utils.parse(source, pos);
} catch (Exception e) {
for (DateFormat dateFormat : formats) {
try {
return dateFormat.parse(source);
} catch (ParseException e1) {
// do notin'
}
}
throw new RuntimeException(e);
}
}
示例6: parseDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
/**
* <p>parseDate.</p>
*
* @param value a {@link java.lang.String} object.
* @param pos a {@link java.text.ParsePosition} object.
* @return a {@link java.util.Date} object.
*/
public static Date parseDate(String value, ParsePosition pos) {
Long timestamp = parseTimestamp(value);
if (timestamp != null) {
return new Date(timestamp);
}
if (value.contains(" ")) {
value = value.replace(" ", "+");
}
if (!(value.contains("-") || value.contains("+")) && !value.endsWith("Z")) {
value += SYS_TZ;
}
try {
return ISO8601Utils.parse(value, pos);
} catch (ParseException e) {
throw new ExtractorException(e);
}
}
示例7: getTimestamp
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
/**
* <p>
* Parses the ISO-8601 date from the image JSON.
* </p>
* <p>
* Handles the bug in the NASA JSON where not all timestamps comply with ISO-8601 (some are missing the 'Z' for UTC
* time at the end of the timestamp).
* </p>
* Uses Jackson ISO8601Utils to convert the timestamp.
*
* @param image
* JSON representation of the image
* @return Java Date object containing the creation time stamp
*/
protected static Date getTimestamp(final JsonNode image) {
Date date = null;
String iso8601 = image.get(IMAGE_TIME_KEY).get(CREATION_TIME_STAMP_KEY).asText();
try {
date = ISO8601Utils.parse(iso8601);
} catch (final IllegalArgumentException e) {
// Don't like this, but not all times have the Z at the end for
// ISO-8601
if (iso8601.charAt(iso8601.length() - 1) != 'Z') {
iso8601 = iso8601 + "Z";
date = ISO8601Utils.parse(iso8601);
} else {
throw e;
}
}
return date;
}
示例8: toJsonShallow
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
public ObjectNode toJsonShallow(final FileStore.File file)
throws RepositoryException {
final ObjectNode json = JsonNodeFactory.instance.objectNode();
json.put("id", file.getIdentifier());
json.put("name", file.getName());
json.put("path", file.getPath());
json.put("mime", file.getMimeType());
json.put("sha512", file.getDigest());
json.put("type", "file");
json.put("parent", file.getParent().getIdentifier());
json.put("accessLevel", file.getAccessLevel().toString());
json.put("modified",
ISO8601Utils.format(
file.getModificationTime().getTime(), true,
TimeZone.getDefault()));
return json;
}
示例9: testGetValueNormalDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Test
public void testGetValueNormalDate() throws Exception {
Date date = new Date();
String strDate = ISO8601Utils.format(date);
new Expectations() {
{
request.getHeader("h1");
result = strDate;
}
};
HeaderProcessor processor = createProcessor("h1", Date.class);
Object value = processor.getValue(request);
Assert.assertEquals(strDate, ISO8601Utils.format((Date) value));
}
示例10: testSetValueDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Test
public void testSetValueDate() throws Exception {
Date date = new Date();
String strDate = ISO8601Utils.format(date);
createClientRequest();
HeaderProcessor processor = createProcessor("h1", Date.class);
processor.setValue(clientRequest, date);
Assert.assertEquals(strDate, headers.get("h1"));
}
示例11: testSetValueDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Test
public void testSetValueDate() throws Exception {
Date date = new Date();
String strDate = ISO8601Utils.format(date);
createClientRequest();
CookieProcessor processor = createProcessor("h1", Date.class);
processor.setValue(clientRequest, date);
Assert.assertEquals(strDate, cookies.get("h1"));
}
示例12: testGetValueNormalDate
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Test
public void testGetValueNormalDate() throws Exception {
Date date = new Date();
String strDate = ISO8601Utils.format(date);
new Expectations() {
{
request.getParameter("name");
result = strDate;
}
};
ParamValueProcessor processor = createProcessor("name", Date.class);
Object value = processor.getValue(request);
Assert.assertEquals(strDate, ISO8601Utils.format((Date) value));
}
示例13: Token
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@JsonCreator
public Token(@JsonProperty("appId") String appId,
@JsonProperty("secret") String secret,
@JsonProperty("creator") User creator,
@JsonProperty("creationTime") String creationTimeAsText) throws ParseException {
this(requireNonNull(appId, "appId"),
requireNonNull(secret, "secret"),
requireNonNull(creator, "creator"),
ISO8601Utils.parse(requireNonNull(creationTimeAsText, "creationTimeAsText"),
new ParsePosition(0)),
creationTimeAsText);
}
示例14: creationTime
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@JsonProperty
public String creationTime() {
if (creationTimeAsText == null) {
creationTimeAsText = ISO8601Utils.format(creationTime);
}
return creationTimeAsText;
}
示例15: format
import com.fasterxml.jackson.databind.util.ISO8601Utils; //導入依賴的package包/類
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
{
String value = ISO8601Utils.format(date, true, CurrentTimeZone.get());
toAppendTo.append(value);
return toAppendTo;
}