incremental development for NIHVIVO-1286 - formatting dateTime literals
This commit is contained in:
parent
d4ca37f85f
commit
48d1403b32
1 changed files with 17 additions and 15 deletions
|
@ -8,7 +8,9 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
|
||||||
import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
|
import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
|
||||||
import com.hp.hpl.jena.ontology.DatatypeProperty;
|
import com.hp.hpl.jena.ontology.DatatypeProperty;
|
||||||
import com.hp.hpl.jena.ontology.ObjectProperty;
|
import com.hp.hpl.jena.ontology.ObjectProperty;
|
||||||
|
@ -117,7 +119,7 @@ public class DateTimeMigration {
|
||||||
|
|
||||||
if (additions.size() > 0) {
|
if (additions.size() > 0) {
|
||||||
long count = additions.size() / 2;
|
long count = additions.size() / 2;
|
||||||
logger.log(count + "Academic Term and/or Year assertion" + ((count > 1) ? "s" : "") + " were updated to use dateTimeInterval instead");
|
logger.log(count + " hasTimeInterval predicate" + ((count > 1) ? "s were" : " was") + " updated to use dateTimeInterval instead");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
aboxModel.leaveCriticalSection();
|
aboxModel.leaveCriticalSection();
|
||||||
|
@ -132,8 +134,8 @@ public class DateTimeMigration {
|
||||||
|
|
||||||
//TODO: look into java locale note: not handling timezones - they are not expected to be in the 1.1.1 data
|
//TODO: look into java locale note: not handling timezones - they are not expected to be in the 1.1.1 data
|
||||||
DateFormat yearFormat = new SimpleDateFormat("yyyy");
|
DateFormat yearFormat = new SimpleDateFormat("yyyy");
|
||||||
DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-mm");
|
DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM");
|
||||||
DateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-mm-dd");
|
DateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
|
||||||
|
@ -212,8 +214,6 @@ public class DateTimeMigration {
|
||||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
StmtIterator iter = aboxModel.listStatements(stmt.getSubject(), dateTimePrecisionProp, (RDFNode) null);
|
StmtIterator iter = aboxModel.listStatements(stmt.getSubject(), dateTimePrecisionProp, (RDFNode) null);
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -230,13 +230,15 @@ public class DateTimeMigration {
|
||||||
|
|
||||||
public static Literal getDateTimeLiteral(Date date) {
|
public static Literal getDateTimeLiteral(Date date) {
|
||||||
|
|
||||||
// Note this loses time zone info, don't know how get parser to extract that
|
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||||
//Calendar cal = Calendar.getInstance( TimeZone.getTimeZone("GMT") );
|
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(date);
|
cal.setTime(date);
|
||||||
|
cal.set(Calendar.HOUR, 0);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.SECOND,0);
|
||||||
XSDDateTime dt = new XSDDateTime(cal);
|
XSDDateTime dt = new XSDDateTime(cal);
|
||||||
return ResourceFactory.createTypedLiteral(dt);
|
String dateString = dt.toString().substring(0, dt.toString().length()-1);
|
||||||
|
return ResourceFactory.createTypedLiteral(dateString, XSDDatatype.XSDdateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String stmtString(Statement statement) {
|
public static String stmtString(Statement statement) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue