on 06-11-2009 1:08 PM
hai all,
can any body suggest how to store system date into a variable.
is there any possibility to store day , month and year into different variable.
how to merge three different variable to form a date.
thanks and regards,
risingstar.
Hi,
wdContext.CurrentContextElement().setVa_Date(new Date(System.currentTimeMillis()); will set the server's current date.
User Calander function of java, to get day, date, month year etc...
Regards,
SrinivaS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you just want the day, month and year from a system date. You can use the following code:
Calendar cal = Calendar.getInstance();
SimpleDateFormat monthFormat= new SimpleDateFormat("MM");
SimpleDateFormat dayFormat= new SimpleDateFormat("dd");
SimpleDateFormat yearFormat= new SimpleDateFormat("yyyy");
SimpleDateFormat dateFormat= new SimpleDateFormat("dd-MM-yyyy");
String month = monthFormat.format(cal.getTime());
String day = dayFormat.format(cal.getTime());
String year = yearFormat.format(cal.getTime());
String dateString = day + "-" + month + "-" + year
Date currDate = (Date) dateFormat.parse(dateString);
Regards,
kartikaye
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For current date use the following code:
java.util.Date currDate = Calendar.getInstance().getTime();
Date todaysDate = new Date(currDate.getTime());
is there any possibility to store day , month and year into different variable.
For setting specific date use thic code Eg June 1 2009:
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, 2009);
cal.set(Calendar.MONTH, 5); //pass 5 for june (i.e normal month no-1)
cal.set(Calendar.DATE, 1);
//Create instance of java.sql.Date
java.sql.Date begDa = new java.sql.Date(cal.getTimeInMillis());
Use java.sql.Date if you to pass to RFC or us can use util.Date
Edited by: Santhosh Edla on Jun 11, 2009 3:40 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can get the current year, month, date as below using Calandar object.
Date myDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(myDate);
int year = cal.get(Calendar.YEAR);
Regards,
Charan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.