NSDate to NSTextField without string Formatting? - nsdate

I want to write the value of a NSDate into a NSTextField but I don't want to format the NSDate into NSString first. The user interface already has an NSDateFormatter object in place and place and it worked fine already when the field was bound to the NSDate.
But now we can't use binding anymore and need to set the Textfield value manually. But we still want to use the NSDateFormatter.
For me it seems like this can not be done. All the samples I found convert the NSDate into a string first before sending it to the TextField. Also if I do it like that I need to convert back the date after the user entered a new value.
How can I do this?

I believe you can use -setObjectValue: (declared on NSControl) to have the NSDate be routed through the attached formatter.
Similarly, the -objectValue method should convert the displayed string back into an NSDate and return that.

Related

Resetting a DateTime-field with invalid data, programmatically

In Dynamics CRM 365:
I'm coding a plugin for a workflow, that's supposed to set a DateTime-field to a given date. The code works fine, unless the field ALREADY contains the value '31-12-9999'.
Every time I try to Update the entity's field with a new DateTime-value I get the following error:
The date-time format for 9999-12-31T23:59:59-00:00 is invalid, or value is outside the supported range.
The format isn't a problem, seeing as it works fine with any other date. I know for a fact the problem is because of the 31-12-9999 in UTC.
As soon as I try to access the field, it tries to convert it to GMT+2 (local timezone) and fails.
The question:
Is there a way to force delete/update the value in a field through a coded plugin?
I have tried with the normal organizationservice CRUD-operations but none of them work.
This should help or give ideas
https://community.dynamics.com/crm/f/117/t/237525
"the date format used for those fetch conditions has to match the date format configured for that user in CRM"

Replaceitemvalue & date field & lotusscript

I am using following code to create a new notes datetime item on the document.
Call doc.replaceitemvalue("dttimefield", format(cdat("11/11/2011"),"d/mm/yyyy"));
It does the work but when I open the document and see the documemnt properties it shows me as text list and having value as "11/11/2011"
Please help me what is wrong here. I want that as date time field not text list.
Thanks
You need to create a NotesDateTime variable with the expected date and then use that variable as input to the replaceItemValue method.
Is it error with ";" or it's Java?
I try with your code and it's get a date/time type.

Date from SQL datebase to JCalander

I used http://toedter.com/ jDateChooser to get the date from user. But now I want to reset the selected date to the calendar from SQL database. This is the code I wrote to put selected date to database.
pst.setString(5, ((JTextField)datead.getDateEditor().getUiComponent()).getText());
I figured it out myself.
java.util.Date dateadx = new SimpleDateFormat("yyyy-MM-dd").parse(dateadm);
Here dateadm is the String variable which you want to store as date in JDateChooser.
Then you can simply call
datead.setDate(dateadx)
to set the date.

How to get the Current Date & Time Automatically to a Date Time Field

I have created a date time field I made today's date as the default value, Then I added it to a page layout and created a page, But the current Date Time is not picking up from the system.
I dont want to give the user to select a Date Time instead it should populated automatically
Is there anyway to achieve this without writing code in code behind files?
This is very similar to this question I think
SO - How to get Date and current time from the Date/Time column in SharePoint Custom list
My answer there gives a few options such as using the built in Created field, using a calendar template, a JavaScript hack and a custom field type.
Guys, fake [Today] trick worked for us - but prob is we only got the date value not datetime.
Janis, is it possible to get date and time both from the fake [today] column trick? pls refer few articles on the same
Does [Today] work?
If you have language pack applied to SharePoint, then you must use localized "Today" string.

Modx assign default date to template variable

I have a template variable of input type date but I'd like to have a default value of the current date at the time the document was first saved.
I've noticed that using the date formatter widget gives an option to "If no value, use current date" however it seems to use the date at the time it is being viewed rather than the date at the time the document was created.
Any help appreciated.
I think the only way to get the date when the article was saved for the first time is to use [ * createdon * ]
If there is a way to add the created date to a TV, I am not sure. I think your best shot would be to see if you have an event that you could "hook" you Template Variable, and then use the createdon variable everytime the article is saved! I am not sure this works, but This could be a possible!

Resources