cancel
Showing results for 
Search instead for 
Did you mean: 

Default Dates for current month

Former Member
0 Kudos

HI all,

I want to set the dates of the current month as default, for ex

Input field1 - 01/03/2009 (default), first day of the current month.

Input field2 - 31/03/2009 (default), last day of the current month.

Regards

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

You may use getDate() method of java.util.date to get current date. Or use getMonth()

to get the current month & getYear() to get current year. Set your first input field in init

method of the view... for example, as "1/<current month>/<current year>".

Then depending upon how many days the current month has, set the last date of the

month in 2nd input field.

There is this document on SDN on how to implement calendar UI in webdynpro.

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e012e6a2-8d21-2a10-1bb8-d9b606f3...

Former Member
0 Kudos

Hi,

Create two context attributes of type Date and bind this to respective ui elements

Use the calendar and date api from java to do this.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi

//last day of month

Calendar c = Calendar.getInstance();

c.set(2009,3,3); //today

c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));

//first date og month

Calendar c2 = Calendar.getInstance();

c2.set(2009,3,3); //today

c2.set(Calendar.DAY_OF_MONTH, c2.getActualMinimum(Calendar.DAY_OF_MONTH));

//test your code

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

System.out.println("last: " + sdf.format(c.getTime()));

System.out.println("first: " + sdf.format(c2.getTime()));

Good luck,

Ola

former_member185086
Active Contributor
0 Kudos

Hi

Use

Calendar c = Calendar.getInstance();

String DATE_FORMAT_NOW = "dd-MM-yyyy";

SimpleDateFormat date_format = new SimpleDateFormat(DATE_FORMAT_NOW);

c.getTime();

date_format.format(c.getTime());

//for current

wdComponentAPI.getMessageManager().reportWarning(date_format.format(c.getTime()) +" ");

c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));

//for last

wdComponentAPI.getMessageManager().reportWarning(date_format.format(c.getTime()) +" ");

Best Regards

Satish Kumar

Edited by: satish jhariya on Mar 3, 2009 5:59 PM