• 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
RE: NSNumberFormatter & NSTimestamp -- Not Happening
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSNumberFormatter & NSTimestamp -- Not Happening


  • Subject: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Tue, 16 Sep 2003 17:19:55 +0100

Thank you Albert
I was close with how I was thinking and where I intended to go, but going by what I'm looking at I wasn't anywhere near close enough.


I'll be testing it in the next day or two as i've moved on to the next problem solve and have to stop coding to attend a birthday party (drrrratt & double drrrratt ;^)). I will let you know how it goes.

Kind regaards
Jonathan :^)

From: "Albert Jagnow" <email@hidden>
To: "Jonathan Fleming" <email@hidden>,<email@hidden>
Subject: RE: NSNumberFormatter & NSTimestamp -- Not Happening
Date: Tue, 16 Sep 2003 09:48:33 -0500




>1.) I have created a custom number formatter to give me a BigDecimal on
a
>'price' textField. This works fine on the WOTexField in WOBuilder, but
when
>I make the save to the database (MSSQLServer2000), instead of 345.45 I
only
>get 345 what am I missing in this senario

What is the column type in the database?  Is it possible you set the
column type to integer?

>2.) I want to establish the lapsed time between two dates so that I can
>perform an automatic delete if an EO has not been updated for that
legth of
>time. Eg. if the last modified date is Sep 01 2003 and the current date
is
>Oct 01 2003 (1 month or 31 days later) I want to perform a delete, how
would
>i write this please?

If you have two NSTimestamps you can get the number of days between them
using a method something like this:

//this is untested code
public int numOfDays(NSTimestamp start, NSTimestamp end){
	long diff = (end.getTime() - start.getTime()); //diff in ms
	int days = (int)( diff / (24*60*60*1000) );
	return days;
}

NSTimestamp now = new NSTimestamp();
if(numOfDays(myObject.timestamp,now) > 60){ //delete objects older than
60 days
	//delete myObject
}

or if what you want to do is delete objects with the date earlier than
the first of the month two months ago, i.e. keep the current month and
two months history, you might do something like this:

public NSTimestamp compareTimestamp(){
	NSTimestamp now = new NSTimestamp();
	NSTimestamp then =
now.timestampByAddingGregorianUnits(0,-2,0,0,0,0);//-2 for months ago
	GregorianCalendar myCal = new GregorianCalendar();
	myCal.setTime(then);
	int year = myCal.get(GregorianCalendar.YEAR);
	int month = myCal.get(GregorianCalendar.MONTH) + 1;
	NSTimeZone tz =
NSTimeZone.timeZoneWithName("America/Chicago",true);
	return (new NSTimestamp(year,month,1,0,0,0,tz) );
}

NSTimestamp ct = compareTimestamp();
if(myObject.timestamp.before(ct)){
	//delete myObject
}

--Albert


This e-mail (including any attachments) is covered by the Electronic Communications Privacy Act, 18 USC. 2510-2521. It is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, and then delete it. Thank you.

_________________________________________________________________ Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile _______________________________________________ webobjects-dev mailing list | email@hidden Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Using Static HREF - Session Problems
  • Next by Date: RE: WebObjects and iCal
  • Previous by thread: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Index(es):
    • Date
    • Thread