Re: NSDates, NSTimestamps and the Java-bridge

Ricardo Strausz <[email protected]> Wed, 14 May 2003 12:10:27 -0500
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
On martes, mayo 13, 2003, at 01:37 America/Mexico_City, Dirk Olmes  
wrote:

> Ricardo Strausz wrote:
>> Hola tod@s!
>> I hope some one can help me with this one:
>> I nead to build a qualifier which bounds some dates... I am writing  
>> almost everything in ObjC (doing Cocoa/EO) but some objects  
>> initializers (like NSTimestamp) don't jump the bridge, so I have also  
>> a Util.java object in charge of those pins...
>> the code is:
>> - (NSArray*)facturasDe:(id)eo desde:(NSCalendarDate*)desde
>> {
>>     [desde setCalendarFormat:@"%d %m %Y"];
>>     id nst = [Util nst:[desde description]]; //this is an NSTimestamp  
>> created by Util.java
>>     NSString* nss = [NSString stringWithFormat:@"fecha>='%@'",[nst  
>> toString]];
>>     id eoq = [EOQualifier qualifierWithQualifierFormat:nss:nil];
>>     [[dgFacturas dataSource] setAuxiliaryQualifier:eoq];
>>     [dgFacturas fetch:self];
>>     return [dgFacturas displayedObjects];
>> }
>>     public NSTimestamp nst(String dateString){
>>         NSTimestampFormatter formatter=new NSTimestampFormatter("%d  
>> %m %Y");
>>         ParsePosition pp = new ParsePosition(0);
>>         NSTimestamp  
>> myNSTimestamp=(NSTimestamp)formatter.parseObject(dateString,pp);
>>         return myNSTimestamp;
>>     }
>> and the error is:
>>  ** Error JDBCColumn for setting date type for 2003-04-12 05:00:00  
>> Etc/GMT- class = class java.lang.String.
>
> That shouldn't come as no surprise. EOF expects an NSTimestamp as  
> argument, you're providing an NSString. What happens when you change:
>
> >     NSString* nss = [NSString stringWithFormat:@"fecha>='%@'",[nst
> > toString]];
>
> to
>
> >     NSString* nss = [NSString stringWithFormat:@"fecha>=%@", nst];
>
> ??
>
>

then I get the error:
2003-05-14 12:08:35.640 Clientes[881]  
com/webobjects/foundation/NSForwardException: Lexical error at line 1,  
column 35.  Encountered: ":" (58), after : ""
Stack Trace:
com.webobjects.foundation.NSForwardException for  
com.webobjects.eocontrol._private.TokenMgrError: Lexical error at line  
1, column 35.  Encountered: ":" (58), after : ""
	at  
com.webobjects.eocontrol._private._EOQualifierParserTokenManager.getNext 
Token(_EOQualifierParserTokenManager.java:1019)
	at  
com.webobjects.eocontrol._private._EOQualifierParser.jj_ntk(_EOQualifier 
Parser.java:1002)
	at  
com.webobjects.eocontrol._private._EOQualifierParser.parseValueList(_EOQ 
ualifierParser.java:501)
	at  
com.webobjects.eocontrol._private._EOQualifierParser.RelOpExpression(_EO 
QualifierParser.java:651)
	at  
com.webobjects.eocontrol._private._EOQualifierParser.Expression(_EOQuali 
fierParser.java:594)
	at  
com.webobjects.eocontrol._private._EOQualifierParser.parseLogicalExpress 
ion(_EOQualifierParser.java:885)
	at  
com.webobjects.eocontrol.EOQualifier.qualifierWithQualifierFormat(EOQual 
ifier.java:938)