Getting individual values from GWT datebox? - gwt

I'm a newbie so please help me in this. I have a datebox with a default date format and its working and displaying selected date in the box as expected.
Now, I need to get individual values from whats being displayed/selected, i.e., month, date, year. I need them to be used to query something in database.
Example : Displayed as July 14th, 2010. I require after displaying it in box, the numeric values as 7(for month), 14(for date), 2010(for the year).
Plese help, I'll be really thankful.
_ Chirayu Diwan

DateBox has a method getValue() which returns an obect of type java.util.Date. This class has individual method to get getYear(), getMonth() (offsets with 0, so 0 is January) and getDay().

Related

how to make a day from date in LibreOffice?

I want to convert date into a Day
I am using LibreOffice
I used some of its syntax weekday and text but it returns nothing
WEEKDAY("30-04-2019"; 1) is there any way to do that?
in google sheet i used =TEXT(C7758,"dddd") but it didn't work
how can I do that?
thanks in advance
Try the combination of functions WEEKDAY and DATE:
=WEEKDAY(DATE(2019;4;30))
The specific example will return 3 which is Tuesday (see all days and other options at https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_WEEKDAY_function)
Hope that helps.

Erlang - invalid/wrong date

How can I validate a date in Erlang?
What happens is that, for example, the date 2018-02-31 is a "valid date" in the sense that I can work with it. When I insert this date on a table (field date) it converts itself to 2018-03-03 (2018-02-28 + 3 days).
What I want is a way to let me know that the original date of my example (2018-02-31) is indeed an invalid date.
Thank you.
Try to use calendar module
calendar:valid_date(Date) -> boolean().
calendar:valid_date(Year, Month, Date) -> boolean().
You will receive true or false
The detailed information and correct input format is here Erlang Calendar Module
I found out that this works just fine for me:
calendar:valid_date()
Thank you.

vb6 error 380 Datepicker, bust just in certain dates

Im having a problem with a datepicker on vb6, but this jus happen on certain dates, for example 31/01/2017, but with another dates it works fine.
I appreciate the help
This almost certainly has to do with how you are setting the date in the control.
For instance if the control's value is ANY month that does not have 31 days then you will get that error. Trying to set the control to 31/02/2017 would cause an error 380.
There are two approaches you can take to fix this.
Reverse the order you set the date components.
dtFecha.Year = Year(fcsAux.Fields("xf3ch4"))
dtFecha.Month = Month(fcsAux.Fields("xf3ch4"))
dtFecha.Day = Day(fcsAux.Fields("xf3ch4"))
Set the Value property instead of the date components. dtFecha.Value = "31/02/2017"
dtFecha.Value = rcsAux.Fields("xf3ch4").Value
The first approach ensures the month is always appropriate for the day. The second approach sets the entire value at one shot and should be a valid date.

Format date and add month to it

I'm currently working with embarcadero c++, this is the first time I'm working with it so it's completely new to me.
What I'm trying to achieve is to get the current date, make sure the date has the "dd/MM/yyyy" format. When I'm sure this is the case I want to add a month to the current date.
So let's say the current date is 08/18/2016 this has to be changed to 18/08/2016 and then the end result should be 18/09/2016.
I've found that there is a method for this in embarcardero however I'm not sure how to use this.
currently I've only been able to get the current date like this.
TDateTime currentDate = Date();
I hope someone will be able to help me out here.
I figured it out.
After I've searched some more I found the way to use the IncMonth method on this page.
The example given my problem is as follows:
void __fastcall TForm1::edtMonthsExit(TObject *Sender)
{
TDateTime StartDate = edtStartDate->Text;
int Months = edtMonths->Text.ToInt();
TDateTime NextPeriod = IncMonth(StartDate, Months);
edtNextPeriod->Text = NextPeriod;
}
After looking at I changed my code accordingly to this
TDateTime CurrentDate = Date();
TDateTime EndDate = IncMonth(CurrentDate, 1);
A date object doesn't have a format like "dd/MM/yyyy". A date object is internally simply represented as a number (or possibly some other form of representation that really isn't your problem or responsibility).
So you don't have to check if it's in this format because no date objects will ever be in this format, they simply don't have a format.
You will have to do additions/subtractions on the Date object that the language or library gives you, THEN (optionally) you can format it to a human-readable string so it looks like 18/08/2016 or 18th of August 2016 or whatever other readable format that you choose.
It might be that the TRANSFER of a date between 2 systems is in a similar format, but then formatting the date like that is entirely up to you.
As for how to do that, the link you posted seems like a possible way (or alternatively http://docwiki.embarcadero.com/Libraries/Berlin/en/System.SysUtils.IncMonth), I'm afraid I can't give you an example as I'm not familiar with the tool/language involved, I'm just speaking generically about Date manipulations and they should ALWAYS be on the raw object.

How can I add several months to a date coming from a date form field?

With DateJS, you'd add e.g. six months to the current date like this:
Date.today().addMonths(6);
However, I need to add 24 months not to today's date, but to a date which a user has typed into a date field. So the today() should in principle be replaced by something like this.getField('begin_date').value.
The result shall be written into another data form field.
I tried hard, but couldn't make it. Can anyone help me out?
Providing the input value is a textual representation of a date, you need to convert it into a Date object at the first place. Then you can work with it as you want.
DateJS has a pretty smart parse() function which does exactly that, so you'd achieve it like this:
Date.parse(this.getField('begin_date').value).addMonths(24)
When a specific date format is needed, like DD.MM.YYYY commonly used in Europe, you can use parseExact() and specify the format. Like this:
Date.parseExact(dateToParse, 'dd.MM.yyyy') // leading zeroes required; parses 01.04.2014 but not 1.4.2014
Date.parseExact(dateToParse, 'd.M.yyyy') // leading zeroes not required; parses both 01.04.2014 and 1.4.2014
Here is a solution that I found for my problem, using DateJS as well:
start = this.getField('begin_date').value;
var d1 = util.scand("dd.mm.yyyy", start);
var myDate = new Date(d1);
result = myDate.addMonths(24);
This works pretty fine, also spanning leap years, except for the 28th of February, 2014/2018/2022 ... ; the result then will be the 28th of February, 2016/2020/2024 ... and not the 29th of February 2016/2020/2024... In these cases it's up to the user to accept the 28th or to manually change the date to the 29th.