cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the date default to systems date.

Former Member
0 Kudos

Hi Friends,

I have one small doubt in WDJ,

inPut.setP_Budat();

above attribute is for input date field and the data type is java.sql.date data type.

Now I want to make the date default to systems date.that date looks like (dd.MM.yyyy) foramat

How can I do this.

Regards

Vijay K

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

use the below code

inPut.setP_Budat(new Date(System.currentTimeMillis()) , will set system date

Regards

Sunitha

Former Member
0 Kudos

Hi Friend,

By using this code i am able to Print Sysdate.

DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");

java.util.Date today = new java.util.Date();

java.sql.Date sqlToday = new java.sql.Date(today.getTime());

inPut.setP_Budat(sqlToday);

Now my Req is i am able to System date by default in date input filed. How can I do this.

Regards

Vijay K

former_member214651
Active Contributor
0 Kudos

Hi,

Try this:

1. Create an Input field in the View under a Transparent Container.

2. Navigate to Dictionaries>Simple Type>right-click "Create new Simple Type"

3. Enter the name and package for the simple type & select the bulit in type as "Date"

4. Switch to "Representation" tab and enter the format as dd.MM.yyyy

5. In the Context Tab, right-click create context attribute

6. Select type as the simple tyoe created in step 3.

7. Bind the Input field's "Vaue" property to the context attribute.

In the wdDoInit() write the following code:

wdContext.currentContextElement().set<contextattributename>(new java.sql.Date(System.currentTimeMillis());

This will load the current date.

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith,

I have one more doubt. how to get last 2days back date.

for Example. I have to two input date fields. i.e From and TO date files. TO Date file must have today date(it comes automatically) From Date filed must 2days Back Date.

EX: From date Having 19.09.2010 and To date Having Today System Date(21.09.2010)

How to do this. Please tell me.

Regards

Vijay

Former Member
0 Kudos

Hi,

You can use the following code to get the two days previous date.



import java.util.Calendar;
...
Calendar currCal = Calendar.getInstance();
currCal.add(Calendar.DATE,-2);
Date date = new Date(currCal.getTimeInMillis());// Set this date to your From date field attribute.
...

Hope it helps.

Regards,

Manoj

Edited by: Manoj on Sep 21, 2010 10:47 AM

Former Member
0 Kudos

Hello Vijay,

You can use the Calende class for getting the current date and also to manipulate the dates that is 2 days before or after. There are many methods in the class which will help you to do so. Please refer to java docs of the calender class for the details of the methods.

http://download.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html

Regards,

Raju Bonagiri

Former Member
0 Kudos

hi,

you can try either this way even,

long twoDay = 2L * 24L * 60L * 60L * 1000L;

java.util.Date d = new java.util.Date();

d.setTime(d.getTime() - twoDay);

It will be helpful.

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

>

> Hi Friends,

>

> I have one small doubt in WDJ,

>

> inPut.setP_Budat();

>

>

> above attribute is for input date field and the data type is java.sql.date data type.

> Now I want to make the date default to systems date.that date looks like (dd.MM.yyyy) foramat

> How can I do this.

>

> Regards

> Vijay K

Hi

Make a simple type and select date as built in type for it and then in the representation tab enter format as dd.MM.yyyy

it will solve the issue

Thanks

Sarbjeet