Canton Console - DateTime Create Command

Hi All,

Have a time dataType in template which captures the current timestamp.

template TestContract
  with
    
    seller : Party 
    buyer : Party 
    createdDateTime : Time
  where
    .....

I’m trying to create a contract in Canton Console by creating and executing the command.

@ val createSellProductContractCmd = ledger_api_utils.create(pkgModuleID.packageId,"ID","TestContract",Map("seller" -> clark, "buyer" -> bruce, "createdDateTime" -> "2022-07-22T14:22:21.828675Z"  ))

but failed with

Error : INVALID_ARGUMENT/COMMAND_PREPROCESSING_FAILED(8,c42c9b95): mismatching type: Timestamp and value: ValueText(2022-07-22T09:06:11.654708Z)

which is correct, I’m passing text value to a timestamp field. I tried passing the value as DateTime (2022-07-22T09:06:11.654708Z), Time(2022-07-22T09:06:11.654708Z), Timestamp(2022-07-22T09:06:11.654708Z) but none of them worked.

Can anyone help me with the correct approach

Thank you!

Hi @prajwalhegde3,

You should be able to use java.time.Instant.parse("2022-07-22T14:22:21.828675Z") to get over this error.

Kind Regards,
Mate

1 Like

Thank you @Mate_Varga.