public static NodeValue makeDateTime(Calendar cal) { XSDDateTime xdt = new XSDDateTime(cal) ; return new NodeValueDateTime(xdt) ; }
public static NodeValue makeDate(Calendar cal) { XSDDateTime xdt = new XSDDateTime(cal) ; return new NodeValueDate(xdt) ; }
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; // time // initialize to default values date[CY]=YEAR; date[M]=MONTH; date[D]=DAY; getTime(str, 0, len, date, timeZone); if ( date[utc]!=0 && date[utc]!='Z' ) { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, TIME_MASK); }
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; int end = getDate(str, 0, len, date); parseTimeZone (str, end, len, date, timeZone); if ( date[utc]!=0 && date[utc]!='Z' ) { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, YEAR_MASK | MONTH_MASK | DAY_MASK); }
/** * Create a typed literal xsd:dateTime from a Calendar object. */ @Override public Literal createTypedLiteral(Calendar cal) { Object value = new XSDDateTime(cal); LiteralLabel ll = LiteralLabelFactory.create(value, "", XSDDatatype.XSDdateTime); return new LiteralImpl(NodeFactory.createLiteral(ll), this); }
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; // get date int end = getYearMonth(str, 0, len, date); date[D] = DAY; parseTimeZone (str, end, len, date, timeZone); if ( date[utc]!=0 && date[utc]!='Z' ) { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, YEAR_MASK | MONTH_MASK); }
/** Convert an javascript date string to an xsd:datetime or xsd:date. Dancing around to ensure that we can construct zoneless times (going via Date forcibly introduces a timezone, which we eliminate by turning it into an xsd:dateTime lexical form). @throws ParseException */ public static Literal parseDateTime(String lex, String type) throws ParseException { boolean hasTimeZone = hasTimeZone(lex); boolean isXSDDate = XSD.date.getURI().equals(type); SimpleDateFormat sdf = dateFormat(hasTimeZone, isXSDDate); Date date = sdf.parse(lex); if (isXSDDate) { return ResourceFactory.createTypedLiteral(xsdDateFormat().format(date), XSDDatatype.XSDdate); } else { if (hasTimeZone) { Calendar cal = Calendar.getInstance( TimeZone.getTimeZone("GMT") ); cal.setTime(date); XSDDateTime dt = new XSDDateTime(cal); return ResourceFactory.createTypedLiteral( dt ); } else { SimpleDateFormat f = new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss" ); String lf = f.format(date); Literal l = ResourceFactory.createTypedLiteral( lf, XSDDatatype.XSDdateTime ); return l; } } }
return new XSDDateTime(date, MONTH_MASK);
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; int end = indexOf (str, 0, len, 'T'); // both time and date getDate(str, 0, end, date); getTime(str, end+1, len, date, timeZone); if ( date[utc]!=0 && date[utc]!='Z') { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, XSDDateTime.FULL_MASK); }
@Override public Literal createTypedLiteral( Object value ) { LiteralLabel ll = null; if (value instanceof Calendar) { Object valuec = new XSDDateTime( (Calendar) value); ll = LiteralLabelFactory.create(valuec, "", XSDDatatype.XSDdateTime); } else { ll = LiteralLabelFactory.create(value); } return new LiteralImpl(NodeFactory.createLiteral( ll ), null) ; }
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; //initialize values date[CY]=YEAR; date[M]=MONTH; date[D]=parseInt(str, 3,5); if ( DAY_SIZE<len ) { int sign = findUTCSign(str, DAY_SIZE, len); getTimeZone(str, date, sign, len, timeZone); } if ( date[utc]!=0 && date[utc]!='Z' ) { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, DAY_MASK); }
/** * This method is invoked when the builtin is called in a rule body. * @param args the array of argument values for the builtin, this is an array * of Nodes, some of which may be Node_RuleVariables. * @param context an execution context giving access to other relevant data * @return return true if the buildin predicate is deemed to have succeeded in * the current environment */ @Override public boolean bodyCall(Node[] args, int length, RuleContext context) { checkArgs(length, context); BindingEnvironment env = context.getEnv(); Node now = NodeFactory.createLiteral( LiteralLabelFactory.create(new XSDDateTime(Calendar.getInstance())) ); return env.bind(args[0], now); } }
return new XSDDateTime(date, YEAR_MASK );
/** * Parse a validated date. This is invoked from * XSDDatatype.convertValidatedDataValue rather then from a local * parse method to make the implementation of XSDGenericType easier. */ @Override public Object parseValidated(String str) { int len = str.length(); int[] date = new int[TOTAL_SIZE]; int[] timeZone = new int[2]; //initialize date[CY]=YEAR; date[M]=parseInt(str, 2, 4); int start=5; date[D]=parseInt(str, start, start+2); if ( MONTHDAY_SIZE<len ) { int sign = findUTCSign(str, MONTHDAY_SIZE, len); getTimeZone(str, date, sign, len, timeZone); } if ( date[utc]!=0 && date[utc]!='Z' ) { AbstractDateTime.normalize(date, timeZone); } return new XSDDateTime(date, MONTH_MASK | DAY_MASK); }