Parse date-time field defined in Swagger file - api

I have an API written in Swagger 2.0 that says an entity has a property called when of type date-time:
properties:
when:
type: string
format: date-time
I don't know how to parse the string. How should I expect the date-time format to looks like? I cannot find this in the Swagger 2.0 documentation

As per the Open API 2.0 spec, the date-time should be defined by RFC3339.
For example:
2016-03-22T21:03:41
1985-04-12T23:20:50.52Z
1990-12-31T15:59:60-08:00
I don't know how to parse the string.
This would depend on the language you're using. In JavaScript, Date.parse(dateString) can easily parse the string. Or in Java, you can refer to Converting ISO 8601-compliant String to java.util.Date to know how to parse the date string.

Related

java.util.Date to kotlinx.datetime.LocalDateTime

I have a value of type java.util.Date which was obtained from a legacy third-party API. Is there a direct way of converting it to kotlinx.datetime.LocalDateTime? I know how to do it only in a roundabout way, such as serializing to String and deserializing, or by converting to java.time.LocalDateTime first and then to the wanted type.
i Think the best thing you can do is to convert it to a string and than convert into a kotlinx.datetime.LocalDateTime
The problem is that not all java types can be converted directly into a kotlin one especially not with the old DataType java.util.Date.
It is also posible with the new DataType java.time.LocalDateTime.

Strict Date Format Using Jackson and Kotlin

I'm using Jackson, Kotlin and Quarkus and my object mapper registers Java Time Module, Kotlin Module and Serialize feature write dates as timestamps has been disabled
I have a data class that represents my request body, it contains an LocalDate field called creationDate by default the format that I get is yyyy-mm-dd.
As the date that come in here is getting used to do a network call, I want to change the format to MM/dd/yyyy to facilitate that
What is the best design that needs to be followed
1.) Get Date in MM/dd/YYYY format and send it ahead ? If so then how can I define a default format for my local date
Or
2.) Get default Local Date format from Client and later parse it to MM/dd/yyyy
The main thing that I am having trouble is define a default format for my date field
data class( val createDate: LocalDate, val accountId: Int) // this is my data class for input request
ISO 8601
The default format that you get, yyyy-mm-dd, is ISO 8601 and is the recommended format for data interchange.
How come you need a different format for your network call, I don’t know. The very best thing would be if you could have that network call changed to accept ISO 8601 format too. Under no circumstances should you let this custom format pollute the JSON that you pass in your request. So second best is to get default date format from client and only format it to MM/dd/yyyy for the network call where this format is required.
Link: ISO 8601 - Wikipedia

C# Bond: string to wstring

In the Bond C# manual, it notes the following:
These following changes will break wire compatibility and are not recommended:
Adding or removing required fields
Incompatible change of field types (any type change not covered above); e.g.: int32 to string, string to wstring
...
But it doesn't explain why. The use case here is that I'm using Bond that connects a C# application with a C++ backend. The field is currently a string. I want to change it to a wstring. The manual notes that C# strings can handle C++ strings and C++ wstrings. Therefore, why I can't I just change the field type from string to wstring? Why does this break wire compat?
In Bond's binary formats, strings are UTF8 encoded (no BOM) and wstrings are UTF16-LE encoded. If you were to switch a field from string to wstring, the reading side would try to interpret UTF8 data as UTF16-LE data. These two encodings are not compatible with each other, hence a field type change from string to wstring is a breaking change.
Note that the manual says "For example C# string can represent either Bond type string or wstring." It does not say anything about C++ types. When working with Bond across C# and C++, there are three type systems: Bond's, C#'s, and C++'s.
If on the C++ side, you want to use something akin to std::wstring to store the field in memory, take a look as using Custom type mapping with the string concept.

How to implement fn:QName in XSLT 1.0?

I am in the process of converting a file written in XSLT 2.0 to XSLT 1.0 so that it can be used in a browser. Would anyone know how to implement something with the same functionality as fn:Qname using only XSLT 1.0?
fn:QName delivers a value of type xs:QName, and there is no such data type in XSLT 1.0, so there can be no equivalent function. You'll have to start by deciding on an alternative representation of QNames: for example you could use the XPath 3.0 notation "Q{uri}local", held as a string. (The xs:QName type also holds a namespace prefix, you need to decide whether you need to do that.)
Assuming you decide to use the representation "Q{uri}local" and that namespace prefixes are not required, implementing an equivalent of fn:QName can then be done straightforwardly using functions such as concat(), contains(), and substring-after().

oData operation consumption with objective-C

I have a really simple WCF service operation GetCurrentBalance. It returns a decimal.
I also have the odatagen generated entity files included in the project, which contains an implementation of the GetCurrentBalance operation returning a string. Calling this method returns me an XML string with the desired value in it.
I also tried using executeServiceOperation method in the generated class and pass in the operation name as a parameter, the returned value again is the same XML string.
Is there a way to extract this value? Or do I have to write a custom parser for it?
Thanks in advance.
Without further informations, if the returned value is a formatted XML string you may try extracting the value using XPath queries, have a look at this to get you started