tr:validateDateTimeRange, validation error on selecting current date when setting max date as current date - jsf

I Use Trinidad 2.1 and using tr:validateDateTimeRange to set maximum date in trinidad input date tag,
<tr:inputDate id="frmCal" value="#{reportsBackingBean.reportsModel.searchFromDt}">
<tr:validateDateTimeRange maximum="#{reportsBackingBean.maxDate}" />
Here reportsBackingBean.maxDate refers current date and in date picker when i select current date and submit the form it shows validation error "The date must be on or before 17/09/2015".
Is this the actual behavior? I need current date should be accepted. Please help

MyFaces has changed its implementation for validateDateTimeRange. You have to give the maximum values for 'hours, minutes, seconds, milliseconds'.
Try this:
<code>Calendar cal = Calendar.getInstance();
cal.setTime(maxDate);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 59);
maxDate = cal.getTime();
</code>
Note: maxDate is the variable which you have it in reportsBackingBean.
https://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_validateDateTimeRange.html

Related

Set flatpickr datetime on last enabled day does not work

I have flatpickr date picker on my webpages. Users can select date and time from range from minDate to maxDate. On create form component I also want to set last value, which user select - selectedDate.
If the selectedDate is from last day, flatpicker ignores it.
My code:
const options: Partial<BaseOptions> = {
minDate: minDate, // "2020-12-05 00:00"
maxDate: maxDate, // "2020-12-24 23:59"
dateFormat: 'Y-m-d H:i',
defaultDate: selectedDate, // "2020-12-24 17:00"
enableTime: true,
};
const picker = <flatpickr.Instance> flatpickr(inputElement, options);
picker.setDate(selectedDate);
After some debugging I found a problem. Flatpicker sets internal maxDate to last midnight 2020-12-24 23:59 => 2020-12-24 00:00 and inside setDate() ignores the selectedDate 2020-12-24 17:00, which is not between minDate maxDate.
I fix that by adding this line of code just before picker.setDate(selectedDate);
// ... init the picker ...
picker.set('maxDate', maxDate);
// ... setDate() ...
This sets internal maxDate to desired datetime and make your selectedDate work well.

Start & End of day in local timezone

I am trying to assign a date range - start/end dates for a process. The catch is that the start date should be the 00:00:00 of the start date and end date should be 23:59:59 of the end date in the timezone that my server is in.
Input is 4/4/2017
Following is my code snippet,
var pEnddate = formatDate (campaign.CMPGN_DTL_TX.CMPGN_END_DT, "yyyy-mm-dd 23:59:59");
pEnddate.then (function ( endDate ) {
var endDate1 = moment.tz (endDate, "America/Phoenix").format ();
campaign.CMPGN_DTL_TX.CMPGN_END_DT = endDate1;
}
It is going good for the first time and saving in UTC as "CMPGN_END_DT" : ISODate("2017-04-05T06:59:59.000+0000")
When I try editing it, the next time the date from my TS is coming as "CMPGN_END_DT" : ISODate("2017-04-05T06:59:59.000+0000"). But, the date is changing to the next date, which is CMPGN_END_DT" : ISODate("2017-04-05T23:59:59.000+0000") because I am hard-coding the time. I'm doing this to ensure I set it to the end of day. Because of this, every time I execute this code (which is when I'm updating the related process), the date is getting incremented by 1.
The only workaround I could figure out was to set it to the EOD without having to hard-code it. Is there some way I can achieve this?

How to display date in UltraWinGrid SummaryRow in MM-dd-yyyy?

I am using UltraWinGrid and displaying the sum of the values using the SummaryRow. I need to display the maximum date in the summary row in MM-dd-yyyy format. Only date should be there. How to achieve this. Thanks in advance...
I got the answer form the site
http://www.csharp-examples.net/string-format-datetime/
SummarySettings SumSummary = new SummarySettings();
e.Layout.Bands[0].Columns["DateColumn"].AllowRowSummaries = AllowRowSummaries.False;
SumSummary = e.Layout.Bands[0].Summaries.Add(SummaryType.Minimum, e.Layout.Bands[0].Columns["DateColumn"]);
SumSummary.DisplayFormat = "{0:dd-MM-yyyy}";

Reset button doesn't clear the default date in the inputtext box

In my managed bean class, i have 2 variables as fromDate and toDate of type java.util.Date. I made the fromDate as an inputText box in jsp so user can enter. In toDate i have an inputText box which has a default value of current Date.
private Date toDate = new Date();
I hav written a reset method inside the MB class having
this.fromDate = null;
this.toDate =null;
on invoking reset method through reset button in the jsp , Only fromDate which I enter is getting cleared. ToDate shows current date without getting cleared.

XPages date only fieldonly

Is it possible to create a date only field in XPages? I have tried the following in the querySaveDocument event but the field still ends up with a time portion of 00:00:00
var notesDoc:NotesDocument = document1.getDocument();
var dt:NotesDateTime = session.createDateTime(#Today());
dt.setAnyTime();
notesDoc.replaceItemValue("MyDateField", dt);
It is not completely clear what you are trying achieve.
You can put an EditBox component on your XPage, then go to the "Data" tab. From there you can change the formatting from String to Date. More options should appear on how to format the date in the field. It will handle passing the date to the back end document.
If it is you want to write directly to the back end document, then here is a page listing samples on working with NotesDateTime.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages
Here is code by Sven:
ndt = session.createDateTime(ndt.getDateOnly());
item.setDateTimeValue(ndt);
error in date items, daylight Saving
Update:
I had to do the same thing and found out that it's working this way in Java agent in 8.5.2FP3:
DateTime dt = session.createDateTime(new java.util.Date());
dt.setAnyTime();
doc.appendItemValue("DT", dt);

Resources