on 10-29-2007 12:24 PM
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
irrelevant. Beg my pardon.
regards.
mz
Message was edited by:
Maxim Zalevski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.