Skip to Content
avatar image
Former Member

Simple question, how to add "millisecond" to a field in mapping

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    May 16, 2008 at 01:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I have tried the following format: (yyyy-mm-dd hh:mi:ss.SSS) and i am getting at least a number 😊 Which seem to be the milliseconds ...

      Thank ! 😉

  • avatar image
    Former Member
    May 16, 2008 at 01:03 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 17, 2008 at 12:27 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 17, 2008 at 05:43 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded