cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Date in input field by hard coding in application

Former Member
0 Kudos

Hi all,

1.I have to make a date(its my choice to set the date) to appear in input field which is date type.

2.How to compare two numbers of type decimal. for example greatest of two numbers

urgent requirement

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

irrelevant. Beg my pardon.

regards.

mz

Message was edited by:

Maxim Zalevski

Former Member
0 Kudos

Hi.

1. Create a context value attribute of type date and bind this to your input field.

2. There is a compareTo method for this.

Warm Regards,

Murtuza

Former Member
0 Kudos

Hi,

Thanks for your reply.

I created context attribute and binded to input field .

My question is how i can set the input field with the date (of my choice).

Input field is of type date.

i am using this code:

wdContext.currentContextElement().setDate(new Date(10/10/2005));

While i am setting this date i am getting the date as(1/1/1970) in the output.

Former Member
0 Kudos

> wdContext.currentContextElement().setDate(new

> Date(10/10/2005));

>

> While i am setting this date i am getting the date

> as(1/1/1970) in the output.

Is it sql.Date or util.Date ?

In case of 'util' Date - wrong input parrameter.

new Date(Date.parse("10/10/2007"));

mz

Former Member
0 Kudos

Hi

Check the http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Date.html

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html

Sample Code

Date now = new Date();

DateFormat df = DateFormat.getDateInstance();

String s = df.format(now);

System.out.println("Today is " + s);

java.sql.Date descends from java.util.Date, but uses only the year, month and day values. There are two methods to create a Date object. The first uses a Calendar object, setting the year, month and day portions to the desired values. The hour, minute, second and millisecond values must be set to zero. At that point, Calendar.getTime().getTime() is invoked to get the java.util.Date milliseconds. That value is then passed to a java.sql.Date constructor:

Calendar cal = Calendar.getInstance();

// set Date portion to January 1, 1970

cal.set( cal.YEAR, 1970 );

cal.set( cal.MONTH, cal.JANUARY );

cal.set( cal.DATE, 1 );

cal.set( cal.HOUR_OF_DAY, 0 );

cal.set( cal.MINUTE, 0 );

cal.set( cal.SECOND, 0 );

cal.set( cal.MILLISECOND, 0 );

java.sql.Date jsqlD =

new java.sql.Date( cal.getTime().getTime() );

The second method is java.sql.Date's valueOf method. valueOf() accepts a String, which must be the date in JDBC time escape format - "yyyy-mm-dd". For example,

java.sql.Date jsqlD = java.sql.Date.valueOf( "2010-01-31" );

creates a Date object representing January 31, 2010. To use this method with a Calendar object, use:

java.sql.Date jsqlD = java.sql.Date.valueOf(

cal.get(cal.YEAR) + ":" +

cal.get(cal.MONTH) + ":" +

cal.get(cal.DATE) );

which produces a Date object with the same value as the first example.

Regards

Ayyapparaj

Former Member
0 Kudos

if u are setting wrong date format, then it is taking default date, which is 1/1/1970