Re: NSDates, NSTimestamps and the Java-bridge

Dirk Olmes <[email protected]> Tue, 13 May 2003 08:37:55 +0200
Newsgroups gmane.comp.web.webobjects.eof
Organization Daedalos AG
Message-ID <[email protected]>
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];

??

-dirk