I have defined a header in my camelcontext file which reads the incoming date and sets into another body. But the problem is the incoming date format is dd-mm-yyyy and I have to pass as MM/DD/YYYY.
/* In this header I am setting the incoming date */
<setHeader headerName="fitnessUpto">
<simple>${exchangeProperty.fitnessUpto}</simple>
</setHeader>
/*But in body I have to pass as MM/DD/YYYY format */
<tm:TMRCValidityDate>${header.fitnessUpto}</tm:TMRCValidityDate>
Can you please suggest how to convert the incoming date format into desired Date format using apache camel, also please attach any dependancy required.
Incoming date format, "fitnessUpto":"11-11-2036" and I have set this in myheader. But want to convert this date format into MM/DD/YYYY and set this new format into Header
You can use this
from("timer:hello?repeatCount=1")
.setProperty("someDateField",constant(new Date()))
.log("${date:exchangeProperty.someDateField:yyyy/MM/dd}");
Related
In my request model, I have a field like
#NotNull
#Schema(example = "19680228", type = "String", format = "yyyyMMdd", pattern = "([0-9]{4})(?:[0-9]{2})([0-9]{2})", required = true, nullable = false)
#JsonDeserialize(using = CustomDateDeserializer.class)
private OffsetDateTime birthDate;
My birthday is of OffsetDateTime type, however, request comming in contains only date portion in format yyyyMMdd. This is requirement and cannot be changed. And this is OK, I already take care of that with my CustomDateDeserializer and it is all working fine.
Based on OpenAPI documentation and some post (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#data-types, What is the correct way to declare a date in an OpenAPI / Swagger-file?), I know that OpenAPI supports ISO8601 date and date-time, in which case, no pattern is needed and type should be provided as date or date-time.
However, in case you require some other format due to legacy code or no ability to change, the documentation states that type should be String, format should specify which format the date is in, and pattern should be provided as regex.
And this is exactly what I am doing in the above #Schema annotation.
However, when I go to https://editor.swagger.io/ and paste my .yaml file into it, the API generated for both my request model and my controller still contain incorrect formatting for birthdate and the example is not even taken into consideration:
Here is how it shows in my model:
As you can see, the format is still getting the format for OffsetDateTime and there is no example at all.
Same for my controller:
How do I make birthday show up as yyyyMMdd? For example, how to make it show as 19720226 in swagger editor?
I am using OpenApi/Swagger 3 in a Spring Boot application.
Hi I've the following json in flowfile: {"destination.port":"0000","network.packets":"1","event.end":"1563361839","source.address":"1.2.2.1","message":"OK","server.address":"ip-1-2-2-3.ec2.internal","event.action":"ACCEPT","event.module":"s3bucket","source.port":"478","network.protocol":"6","cloud.account.id":"123456","event.type":"data","organization.id":"Fusion","destination.address":"1.2.2.2","network.bytes":"60","event.start":"1563361837","event.kind":"2","host.id":"eni-06f72","timestamp":"2019-07-17T11:16:39.792Z"} with event.end and event.start as epoch.
I'm using nifi-1.9.2.
Help me convert the epoch to date in UTC and replace the same. I have tried using updateAttribute processor with /event.start=${event.start:format("yyyy-MM-dd HH:mm:ss.SSS")}, didn't go right. I have done some reading for a processor but couldn't. Thanks
The source to your problem is how you try to extract event.start from the JSON. The expression language is used for manipulating FlowFile's attributes, and not content of your FlowFile.
If this JSON is in the content of your FlowFile, then use EvaluateJsonPath, with Destination property set to flowfile-attribute and new custom property named event.start set to $['event.start'].
And now that you have it as attribute, transfer it to JoltTransformJSON with Jolt Transformation DSL set to Modify - Overwrite and Jolt Specification set to:
{
"event.start": "${event.start:append('000'):format('yyyy-MM-dd HH:mm:ss.SSS')}"
}
The appended 3 zeros are since epoch in NiFi is in milliseconds.
How can I pass a date/time parameter to my report via url. I only have access to the DDMMYY format of the date. I know I should tell SSRS what language to use with the
rs:ParameterLanguage=de-DE
But I dont know what language DDMMYY is.
http://<>/ReportServer/Pages/ReportViewer.aspx?/<>/<>/report¶1=801¶2=1000011&DATE=070415&rs:ParameterLanguage=???
Oké, I guess this is not possible, but I added a hidden text parameter to the report so I could convert is with custom vbscript. and let the query decide what to use as the date parameter.
I'm using spring ws 2.0.2.RELEASE
I have a web service that creates a sales order
Two of the elements in the SOAP call are dates:
<ns3:requestedDate>2012-06-06T01:00:00.000+10:00</ns3:requestedDate>
<ns3:orderDate>2012-06-06T10:25:09.681+10:00</ns3:orderDate>
Both fields are defined in the schema as xs:dateTime
When I send through the SOAP call to my service I get:
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-datatype-valid.1.2.1: '2012-06-06T01:00:00.000+10:00' is not a valid value for 'date'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.3.1.3: The value '2012-06-06T01:00:00.000+10:00' of element 'ns3:requestedDate' is not valid.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-datatype-valid.1.2.1: '2012-06-06T10:25:09.681+10:00' is not a valid value for 'date'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.3.1.3: The value '2012-06-06T10:25:09.681+10:00' of element 'ns3:orderDate' is not valid.</spring-ws:ValidationError>
</detail>
</SOAP-ENV:Fault>
Any idea why these valid dates are being reported as invalid by Spring?
It seems if I pass in just the date portion '2012-06-06' it all works. I suppose the clue here should have been 'date' as opposed to 'datetime'. The end point being called must be expecting only a date.
Probably the date format. It's parsing the date in the format YYYY-MM-DD but a lot of validators pass what is basically the universally accepted internet format of DD-MM-YYYY. Had similar trouble recently with validating a form in mobile safari. Try changing the date format and see if that works.
I have a ruby model that contains a date attribue which I'd like to be able to pass in as a parameter in the format dd/MM/yyyy.
However, my sqlite3 db stores the data in yyyy-MM-dd format so when a date like 20/10/2010 gets passed in, it will not be read to the database.
I am using the Sinatra framework and using haml for the markup creation.
Do I need to write a helper that takes the date string and converts it to the correct format for the db? Or can I set a format type on the models attribute?
Thanks.
You shouldn't need to worry about the database's internal representation of the date; DataMapper is there to do that for you. You just need to make sure you are passing it a valid Date object.
Check out http://ruby-doc.org/core/classes/Date.html for methods available to the Date class. For your example:
require 'date'
mydate = '20/10/2010'
mydate_obj = Date::strptime(mydate, '%d/%m/%Y')
puts "#{mydate_obj}" # prints 2010-10-20
I don't know if this can help, some time ago I had the same problem: I was using Rack::Utils.escape_html(params[:datetime]) to escape html on user input and if I typed a date in a form field like this "25/02/2013" it would be sent to the DataMapper model like this: 16/02/2013 (with escaped html codes) so it was saving it the wrong way (day ended up being the hour or something similar).
Maybe you are also using "escape_html" method in an awkward way?