PDA

View Full Version : Date field help needed



shajeerkt
7 Nov 2009, 5:34 AM
I have some problems with my Datefield
i have a date field and i had set the required format.
Now i have the format as 04.11.2009 and it displays correctly in the date field.
What i need is i want to get the same date as a String value

for eg,in my console if i am trying to print it
System.out.println(fromDate.getValue());
i am getting as Wed Nov 04 00:00:00 AST 2009
what i need is 04.11.2009 itself.

Since i need to get as String is i want to use this String value to do some filtering in my server side.

I know this is a silly question.But not able to trace it



final DateField fromDate = new DateField();
fromDate.setFieldLabel("From Date");
fromDate.setEmptyText("From Date");
fromDate.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd.MM.yyyy"));
fromDate.addListener(Events.Change, new Listener<FieldEvent>(){
public void handleEvent(FieldEvent be) {

System.out.println(fromDate.getValue());

}

shajeerkt
7 Nov 2009, 10:53 PM
Got the solution .



final DateField fromDate = new DateField();
fromDate.setFieldLabel("From Date");
fromDate.setEmptyText("From Date");
fromDate.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd.MM.yyyy"));
fromDate.addListener(Events.Change, new Listener<FieldEvent>(){
public void handleEvent(FieldEvent be) {

DateField fd = (DateField)be.getField();
String from_date = fd.getRawValue();

}

takayser
8 Nov 2009, 6:01 AM
DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("EEEE, d. MMM yy, HH:mm");
String stringrep = dateTimeFormat.format(dateField.getValue());