AGTemporalDateTime.java

package com.franz.ag.examples;

import org.openrdf.model.Literal;

import com.franz.ag.AllegroGraph;
import com.franz.ag.AllegroGraphConnection;
import com.franz.ag.AllegroGraphException;
import com.franz.ag.Cursor;

public class AGTemporalDateTime {

    /**
     * Demonstrates some basics of working with date-time objects.
     * 
     * @param unused
     * @throws AllegroGraphException 
     */
    public static void main(String[] args) throws AllegroGraphException {

        // Connect to server, which must already be running.
        AllegroGraphConnection ags = new AllegroGraphConnection();
        try {
            ags.enable();
        } catch (Exception e) {
            throw new AllegroGraphException("Server connection problem", e);
        }
        // Create a fresh triple-store for this example.
        AllegroGraph ts = ags.renew("datetime", AGPaths.TRIPLE_STORES);
        
        // Register your namespaces
        ts.registerNamespace("ex","http://example.org/");
        
        Literal lit = ts.createEncodedLiteral("2000-01-01T00:00:00-00:00","date-time");
        AGUtils.showLiteral(lit);
        ts.addStatement("!ex:person1","!ex:birthdate", lit);
        Cursor cc = ts.getStatements(null, "!ex:birthdate", lit);
        AGUtils.showTriples(cc);
        
        // Close the triple store and disconnect from the server
        ts.closeTripleStore();
        ags.disable();
        
    }

}

Up | Next