Issue 226 - Format dates as ISO 8601 for compatibility with Freebase graph
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2451 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
4a99abf25d
commit
bfc275de5f
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright 2010, Google Inc.
|
Copyright 2010,2012. Google Inc.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@ -35,6 +35,10 @@ package com.google.refine.freebase.protograph.transpose;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -365,7 +369,7 @@ public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory
|
|||||||
boolean first = true;
|
boolean first = true;
|
||||||
boolean firstRecon = true;
|
boolean firstRecon = true;
|
||||||
|
|
||||||
if (subjectCell.recon != null) {
|
if (subjectCell != null && subjectCell.recon != null) {
|
||||||
sbRecon.append("\"s\" : ");
|
sbRecon.append("\"s\" : ");
|
||||||
writeRecon(sbRecon, project, subjectRowIndex, subjectCellIndex, subjectCell);
|
writeRecon(sbRecon, project, subjectRowIndex, subjectCellIndex, subjectCell);
|
||||||
|
|
||||||
@ -847,7 +851,11 @@ public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory
|
|||||||
|
|
||||||
static protected Object validateValue(Object value, String valueType) {
|
static protected Object validateValue(Object value, String valueType) {
|
||||||
if ("/type/datetime".equals(valueType)) {
|
if ("/type/datetime".equals(valueType)) {
|
||||||
if (!(value instanceof String)) {
|
if (value instanceof Calendar || value instanceof Date) {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
value = formatter.format(value instanceof Date ? ((Date) value)
|
||||||
|
: ((Calendar) value).getTime());
|
||||||
|
} else if (!(value instanceof String)) {
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
}
|
}
|
||||||
} else if ("/type/boolean".equals(valueType)) {
|
} else if ("/type/boolean".equals(valueType)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user