on 05-16-2008 1:50 PM
Hi,
We need to add a timstamp to a field at runtime. The mapping function we used is: currentDate .... but the mask for time does not contains millisecond ...
dd/MM/yyyy HH:mm:ss
How can we get millisecond?
merci ! A+
mo
Hi,
By using UDF we can achieve this,
write UDF like this, here no need to give the input parameter if you want the system current date.
1.import java.util.Date;
2.long msec = System.currentTimeMillis();
3.return msec.
If you want to give some date rather than system date then
1.import java.util.Date;
2.input parameter dat;
3.long msec = dat.currentTimeMillis();
4.return msec.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please try this:
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
Object attributeValue = wdContext.currentDateFieldsElement().getAttributeValue(fieldName);
Date theDate =
(Date) wdContext.currentDateFieldsElement().getAttributeValue(
fieldName);
IWDAttributeInfo attributeInfo =
wdContext.nodeDateFields().getNodeInfo().getAttribute(fieldName);
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Date currentDate = new Date(c.getTimeInMillis());
if (theDate.before(currentDate)) {
{
// Throw an error message
msgMgr.reportContextAttributeMessage(
wdContext.currentDateFieldsElement(),
attributeInfo,
IMessageRequisitionForm.MISSING_INPUT,
new Object[] { fieldLabel },
true);
}
}
}
Reward points if this helps
Regards
Vani.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
don't know if it's possible with standard functions, but
you could write a UDF and using:
(import java.util.Date;)
long t0 = System.currentTimeMillis();
and then you can concat the value.
If you need just the format you can also concat a constant "0000".
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to have milliseconds in a date format, try to use the "S" pattern (yyyy-mm-dd hh:mi:ss.SSS) in the datetrans function (it should work cuz it is built upon the SimpleDateFormat class) or write your own UDF importing the java.text.SimpleDateFormat package.
I use it to format debug log time stamps and it works pretty fine
Rgds
Chris
hi
write a UDF and do it
use Date/Calender java classes
use this code
Calendar now = Calendar.getInstance();
String millisec=String.valueOf(now.getTimeInMillis());
return millisec;
rgds
Arun
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.