• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTimestamp - date-timestamp data fetching issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTimestamp - date-timestamp data fetching issues


  • Subject: NSTimestamp - date-timestamp data fetching issues
  • From: Raghavender Bokka <email@hidden>
  • Date: Wed, 22 Jun 2011 18:59:13 +0530

Hi Team,

I am trying to fetch the records using NSTimestamp values (that includes date, hours and minutes), and the data is fetched correctly based on the given date and time range parameters.

But when I tried printing the fetched Object, the date fields of the object are printing as (2011-01-27 05:00:00 Etc/GMT), all the date fields hour, minutes and seconds are printing as 05:00:00, even though this value is different for different columns in the database.

Please advise on how to fetch the date field values exactly including the hour and minutes.

Following is the code snippet attached for reference:

------------------------------------------------------------------------------------------------------------------------
NSMutableArray qualifiers = new NSMutableArray();

    

    GregorianCalendar calendarStartDate = new GregorianCalendar();
    calendarStartDate.setTime(startingDate);

    

    int startDay = calendarStartDate.get(GregorianCalendar.DAY_OF_MONTH);
    int startMonth = calendarStartDate.get(GregorianCalendar.MONTH);
    int startYear = calendarStartDate.get(GregorianCalendar.YEAR);

    

    int startHour = 0;
    int startMinute = 0;

    

    if(reportParameters.valueForKey("startHour") != null)
    startHour = Integer.parseInt((String)reportParameters.valueForKey("startHour"));

    

    if(reportParameters.valueForKey("startMinute") != null)
    startMinute = Integer.parseInt((String)reportParameters.valueForKey("startMinute"));

    

    NSTimestamp startDate = new NSTimestamp(startYear,startMonth+1,startDay,startHour,startMinute,0,NSTimeZone.defaultTimeZone());

    

    GregorianCalendar calendarEndDate = new GregorianCalendar();
    calendarEndDate.setTime(stoppingDate);

    

    int endDay = calendarEndDate.get(GregorianCalendar.DAY_OF_MONTH);
    int endMonth = calendarEndDate.get(GregorianCalendar.MONTH);
    int endYear = calendarEndDate.get(GregorianCalendar.YEAR);

    

    int endHour = 0;
    int endMinute = 0;

    

    if(reportParameters.valueForKey("endHour") != null)
    endHour = Integer.parseInt((String)reportParameters.valueForKey("endHour"));

    

    if(reportParameters.valueForKey("endMinute") != null)
    endMinute = Integer.parseInt((String)reportParameters.valueForKey("endMinute"));

    

    NSTimestamp endingDate = new NSTimestamp(endYear,endMonth+1,endDay,endHour,endMinute,0,NSTimeZone.defaultTimeZone());

    

    EOQualifier startDateQualifier = new EOKeyValueQualifier("elapsedTime",EOQualifier.QualifierOperatorGreaterThanOrEqualTo,startDate);
    qualifiers.addObject(startDateQualifier);

    

    EOQualifier stopDateQualifier = new EOKeyValueQualifier("elapsedTime",EOQualifier.QualifierOperatorLessThanOrEqualTo,endingDate);
    qualifiers.addObject(stopDateQualifier);

     .....


    EOFetchSpecification stsFetchSpecification = new EOFetchSpecification(<ENTITY-NAME>,new EOAndQualifier(qualifiers),null);
    NSArray entityObjects = editingContext.objectsWithFetchSpecification(stsFetchSpecification);

     ......

----------------------------------------------------------------------------------------------------------------------------------

Regards,
Raghu.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSTimestamp - date-timestamp data fetching issues
      • From: Кушнир Геннадий <email@hidden>
  • Prev by Date: Re: MS SQL Server plugin
  • Next by Date: Re: d2w - huh?
  • Previous by thread: Re: d2w - huh?
  • Next by thread: Re: NSTimestamp - date-timestamp data fetching issues
  • Index(es):
    • Date
    • Thread