cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Current Time

Former Member
0 Kudos

hi,

i am setting the current date in WD Java using the following code:

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

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

wdContext.currentContextElement().setmydate(sqlToday);

it is functioning correctly.

my question is:

How to set the current time?

Regards

Adnan

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

wdContext.currentContextElement().setmydate(new Date (System.currentTimeMillis())); //--This will give you current date.

Calendar cal = Calendar.getInstance();

cal.getTime() ; //---- This will give you time.

Edited by: Swati Gaur on Jan 8, 2009 11:32 AM

Edited by: Swati Gaur on Jan 8, 2009 11:34 AM

Former Member
0 Kudos

Hi,

Use this method.

System.DateTime.Now.ToShortTimeString

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Hi Adnan,

To get the current time you can use the below code

Calendar cal = Calendar.getInstance();

cal.getTime();// This will give you current time

Now if you want to print the date in desired format then you can use below mentioned code.

SimpleDateFormat sdf = new SimpleDateFormat("dd MMMMM yyyy");

String Date = sdf.format(cal.getTime();

Hope this will help

Regards

Narendra Singh

Former Member
0 Kudos

Hi,

wdContext.currentContextElement().setmydate(System.DateTime.Today.TimeOfDay.ToString());

if not use

System.DateTime.Now.ToShortTimeString

Regards,

Srikanth Reddy.T

Former Member
0 Kudos

Hi,

Use Below Code for setting a time & date


SimpleDateFormat fSDateFormat = null;
fSDateFormat = new SimpleDateFormat ("EEE, d MMM yyyy HH:mm:ss Z");
java.util.Date now = new java.util.Date ();
String date_out = fSDateFormat.format (now);
wdContext.currentContextElement().setmydate(date_out);

Regards,

P.Manivannan

Former Member
0 Kudos

Hi P.Manivannan,

this code is giving an error:

"The method setmydate(Date) in the type IPrivateCreateView.IContextElement is not applicable for the arguments (String)"

Regards

Adnan

Former Member
0 Kudos

Hi,

Change attribute type from date to string

Regards,

P.manivannan

Former Member
0 Kudos

Hi Adnan,

Convert is from date to string :



String bldate=item.getBilling_Date();
	   
										String byy=bldate.substring(0,4);
										String bmm=bldate.substring(4,6);
										String bdd=bldate.substring(6,8);
										String bdate=byy+"-"+bmm+"-"+bdd;					
										java.sql.Date bildate=java.sql.Date.valueOf(bdate);
	
							
elem1.setBilling_Date(bildate); 

Regards

Khushboo