on 01-03-2018 2:43 AM - last edited on 02-04-2024 2:28 AM by postmig_api_4
my view code:
<ObjectAttribute
title="{i18n>dateTitle}"
text="{
path: 'invoice>ShippedDate',
type: 'sap.ui.model.type.Date',
formatOptions: {
style: 'long',
source: { pattern: 'yyyy-MM-ddTHH:mm:ss' } } }"/>
ShipppedDate information:
<d:ShippedDate m:type="Edm.DateTime">1997-10-13T00:00:00</d:ShippedDate>
when i run my project , the erroe occured,the error information is :The given date instance isn't valid
please give me a hand,thank you!
Hi,
Try this
<ObjectAttribute
title="{i18n>dateTitle}"
text="{
path: 'invoice>ShippedDate',
type: 'sap.ui.model.type.Date',
formatOptions: {pattern: 'yyyy-MM-dd'}
}"/>
pattern can be 'yMd' or 'yMdhms' or etc..
See
Hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alila,
May be you can try with this formatoptions:
{source:{pattern:"timestamp"}, pattern:"yyyy-MM-dd"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks your answer, using one row code just as yours , the app run well, can show the date information, but the date format is not my need, we need the pattern like
pattern: 'yyyy-MM-ddTHH:mm:ss'
the following code occured the error:
<mvc:View
controllerName="sap.ui.demo.wt.controller.Detail"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:wt="sap.ui.demo.wt.control">
<Page
title="{i18n>detailPageTitle}"
showNavButton="true"
navButtonPress="onNavBack">
<ObjectHeader
responsive="true"
fullScreenOptimized="true"
number="{
parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}],
type: 'sap.ui.model.type.Currency',
formatOptions: {
showMeasure: false
}
}"
numberUnit="{view>/currency}"
intro="{invoice>ShipperName}"
title="{invoice>ProductName}">
<attributes>
<ObjectAttribute title="{i18n>quantityTitle}" text="{invoice>Quantity}"></ObjectAttribute>
<ObjectAttribute title="{i18n>dateTitle}" text="{
path: 'invoice>ShippedDate',
type: 'sap.ui.model.type.Date',
formatOptions: {
style: 'long',
source: {
pattern: 'yyyy-MM-ddTHH:mm:ss'
}
}
}"/>
</attributes>
</ObjectHeader>
<wt:ProductRating class="sapUiSmallMarginBeginEnd" change="onRatingChange"/>
</Page>
</mvc:View>
Please give me hand.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's means you Date type field haven't nullable attribute, you should go to your entity and set Nullable = true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the '{invoice>ShippedDate}' come from :https://services.odata.org/V2/Northwind/Northwind.svc/Invoices
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As I can only see part of the code, can you tell me if the problem persists if you replace ObjectAttribute with this
<ObjectAttribute title="Test title" text="{ path: 'invoice>ShippedDate' }"/>
The clear point is to narrow it down to the place where the problem arises.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.