I am trying to display the date format "dd/MM/yyyy" in an example json in Swagger. However, when I want to show it, it shows me like this:
{
"contractCode": 0,
"registers": 0,
"totalDue1": 0,
"totalDue2": 0,
"buildingExpenses": [
{
"ownersAssociationCode": 0,
"functionalUnitCode": 0,
"period": "hola",
"ownerName": "string",
"location": "string",
"ownerEmail": "string",
"dueDate1": "2021-12-20T00:00:00",
"amount1": 0,
"amount2": 0,
"electronicPaymentCode": "string",
"barcode": "string"
}
]
}
I tried to format it with parse and parseExact, but neither worked. I leave my code: public class BuildingExpenseModeExample : IExamplesProvider
{
public object GetExamples()
{
var dueDate1 = DateTime.Now.ToString("dd/MM/yyyy");
return new BuildingExpenseResumeInputDto
{
ContractCode = 0,
Registers = 0,
TotalDue1 = 0,
TotalDue2 = 0,
BuildingExpenses = new List<BuildingExpenseDetailInputDto>
{
new BuildingExpenseDetailInputDto
{
OwnersAssociationCode = 0,
FunctionalUnitCode = 0,
Period = "hola",
OwnerName = "string",
Location = "string",
OwnerEmail = "string",
DueDate1 = DateTime.ParseExact(dueDate1, "dd/MM/yyyy", CultureInfo.InvariantCulture),
//DueDate1 = DateTime.ParseExact(DateTime.Today.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture),
Amount1 = 0,
Amount2 = 0,
ElectronicPaymentCode = "string",
Barcode = "string"
}
}
};
}
}
I hope you can help me!