Independently configure date format for XML/JSON serialization
How do I configure the date format independently for each of my date fields?
For example, let's say I have a CustomerOrder class with more than 1 java.util.Date fields in it.
I need to be able to render like this:
<customerOrder>
<orderDate>2013-01-04T20:50:42.769Z</orderDate>
<user>Bob</lastUpdateUser>
<state>CO</state>
<estShipDate>2013-01-04</estShipDate>
</customerOrder>
So one of the dates may not care about the hh:mm:ss.
i.e. I cannot format every date the same way.
Any ideas?
This is my technology stack:
- Tomcat 7
- Jersey 1.16
- Enunciate 1.26.2
- Spring 3.1.2
- Hibernate 4.1.7
- JPA 2.0.3
Otis,
A "java.sql.Date" contains only a date, whereas a "java.sql.Timestamp" contains both date and time. So retrieve the data (from the database) as a "Timestamp" and not as a "Date".
Perhaps if you'd care to post the relevant part of your code and show what you are getting and what you want to get, I may be able to help you further.
Here's a small (uncompiled and untested) example:
Connection conn = // However you get it.
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select sysdate from dual");
if (rs.next()) {
Timestamp ts = rs.getTimestamp(1);
}Good Luck,
Avi.
Similar Messages
-
How to change date format for xml insert to a view
We want to accept more than one data format in an XML insert using DBMS_XMLSave.insertXML(insCtx,xmlDoc);
The two formats are
6/7/2004 10:47:21 - This is working
2004-06-08-04:00 - This gives the error
java.text.ParseException: Unparseable date: "2004-06-08-04:00"'Make the column datatype VARCHAR2
-
I have a Date object and I want it to be in the below format before I set it into a Calendar
2009-10-09T17:00:00Z
Here's my code
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
How do I do that?
Thanksuser8742475 wrote:
Here's my code
String dateString = "2011-09-08T00:00:00-0700-07:00";
SimpleDateFormat dfISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
Date dt= dfISO8601.parse(dateString);
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
customObject.setDStartDate(cal); //customObject is a WS object of Oracle CRM On Demand. I downloaded the WSDL and generated the proxy for it. It accepts a Calendar object
Some possible solutions.
1. It will also accept something else. I suggest using the SimpleDateFormat to produce a string and use that and nothing else.
2. It won't accept anything else. Then you are left with the possibility that the WSDL is wrong (somehow) So you find a way to work around it which might include not using the WSDL at all.
3. Depending on how setDStartDate() works you might be able to create a proxy Calendar class, your own implementation, specifically replacing toString() with a correct format based on SimpleDateFormat. -
Hi,
I am relatively new to XML and JSP.I am on a project where i have to transfer data to and from an Oracle 8i database to XML using JSP.everything worked fine except for the follwing:
the date format in xml is always 'yyyy-mm-dd HH:MM:SS'.
the datatype is date in oracle and string in jsp.when i try to upload the data in XML to oracle it gives me date format not recognised error.I ve tried using trunc and to_char in the query which fetches records into a recordset in JSP but to no avail.i keep getting the same format.
Can someone please help with with having the date format as 'dd-mon-yyyy'.
Thanks a heap for the help
regards,
VinayakHi,
I ve tried out the solutions suggested by you and tried using java.sql.Timestamp
as follow:
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="oracle.sql.*" %>
String dateString = rset.getString("installation_dt");
java.sql.Timestamp date = new java.sql.Timestamp.valueOf(dateString);
But tomcat throws up the following error
:104:
cannot resolve symbol
symbol : class valueOf
location: class java.sql.Timestamp
java.sql.Timestamp date = new java.sql.Timestamp.valueOf(dateString);
Hope you can help me.
Thanks a heap
Regards,
Vinayak -
Invalid date format for 'Created' field in the getVersions web service Response.
Hi all,
I am trying to get all versions for selected document by calling getVersions method Versions.asmxweb service, but getting ‘Created’ date attribute value is in the format "29-05-2012 12:01"
but I am expecting either one of the following date formats.
1. yyyy-MM-dd HH:mm:ss or yyyy-MM-ddTHH:mm:ssz
2. MM/dd/yyyy HH:mm a (a means AM/PM)
3. MM/dd/yyyy
4. yyyyMMdd HH:mm:ss
where do I need to change?
what are all the formate will be support by SharePoint?
please find attached response xml of getVersions call.
<results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<list id="{6A6F6CD1-2E9C-44CC-B1F5-56G7JB5C8778}"/>
<versioning enabled="1"/>
<settings url="http://hbngjfgj47s20/reg/_layouts/LstSetng.aspx?List={7S6F6CD1-2E9C-44CC-B1F5-KO9J8Y7Y6H78}"/>
<result version="@0.3" url="http://vmesxsrv47s20/register/Shared Documents/Parent/child/my_doc" created="29-05-2012 12:01" createdRaw="2014-12-02T12:46:02Z" createdBy="my_dom\agi_sharepoint"
createdByName="AGI_Sharepoint" size="288" comments=""/>
<result version="0.1" url="http://hbngjfgj47s20/register/_vti_history/1/Shared Documents/Parent/child/my_doc" created="29-05-2012 10:01" createdRaw="2014-12-02T10:55:18Z" createdBy="my_dom\my_sharepoint"
createdByName="my_sharepoint" size="288" comments=""/>
<result version="0.2" url="http://hbngjfgj47s20/register/_vti_history/2/Shared Documents/Parent/child/my_doc.txt" created="29-05-2012 11:01" createdRaw="2014-12-02T10:59:25Z" createdBy="my_dom\my_sharepoint"
createdByName="my_sharepoint" size="288" comments=""/>
</results>
Kindly help me on this.Hi,
According to your post, my understanding is that you want to change date format for ‘Created’ field in the getVersions web service.
Per my knowledge, you can get the date format for ‘Created’ field as “MM/dd/yyyy HH:mm a”.
For more information, you can refer to:
Versions.GetVersions Method (Versions)
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
How to change the date format in xml form?
hi,
How to change the date format in xml form?
For example: 11/20/2008 3:00:03 PM -> 11-20 03:00
Any opinions greatly appreciated!
Thanks.
Edited by: ke wenxing on Dec 2, 2008 8:33 AMYou could go to System - User Profile - Own Data would take you to the "maintain user profile screen"
Click the defaults button and change the date format.This changes date format for all the dates in your login. -
Where does one manage date formats for display and input
the user specification is that dates be displayed as YYYY-MON-DD. Is there a config or properties file which contains the date format for display? Is there a calendar drop-down that can be positioned next to a date input field for a question on a screen?
Thanks,
AllanHi Allan,
Curious why the rule project wasn't created with "English (Canada)" initially? If your project is English (UK) with the default configurations for that locale, then I assume your currency values are appearing in OWD with the GBP symbol (£) instead of a dollar sign ($)?
As for the impact of switching… I highly recommend getting confirmation from the OPA Dev team before doing it, but in the meantime, if you wanted to experiment on your own with a separate test rulebase (as opposed to whatever formal rulebase you're working on), here are my observations from an initial look… (FYI, I'm an experienced OPA rulie, but I'm non-technical and not in the Dev team, so best to check with them!)
I poked around the language parser files and saw that English (UK) has an English (UK) verb list, whereas English (Canada) uses the English (US) verb list. The vast majority of verbs are identical in all the variations of English, however, there are a couple which differ. So if you've used any verbs which have a different spelling between the 2 lists, there may be some attribute text to tweak, e.g.
- English (UK): the person travelled to Australia
- English (US): the person traveled to Australia
- English (UK): the person cancelled the reservation
- English (US): the person canceled the reservation
I saw some other different files between English (Canada) vs English (UK), but didn't notice anything in them which I'd expect to impact the rulebase.
As for how it might impact other components:
* screens file and the properties file – May be some tweaking depending on how you addressed the verb spelling issue above.
* regression test files – May be some tweaking depending on how you addressed the verb spelling issue above.
* messages.(locale).properties – The default messages.(locale).properties file appears to be based on the Language setting of the Project. I just tested this and OWD used a different messages.(locale).properties file when I changed the Project Language (OPM | File menu | Project Properties | Common Properties | General | Language).
* Siebel Connector – don't know what the impact would be.
OPA Dev team – Can you review what I've said here? And add any relevant further detail?
Cheers,
Jasmine -
Supported date formats for sorting
Can someone point me to a document describing the supported
date formats for sorting? I mean, how should I format a date column
in an XML dataset in order to have this column correctly sorted
using the Spry framework?
Thank you and sorry if the question is trivial.Thanks, what I have done for the moment as a temporary
solution is to use the two date formats and have them both inside
the one cell in the table (the column for the sortable date
yyyy-mm-dd). In my CSS I have created a style for the first date
that has it's visibility as hidden. That way it's sorting the Date1
but only Date2 is being shown to the users as the other cells have
more than one line of text it doesn't look too off centre.
<div spry:region="ds2">
<table width="662">
<tr>
<th width="127" class="eventhead"
spry:sort="Date1">Date</th>
<th width="151" class="eventhead"
spry:sort="Type">Type</th>
<th width="146" class="eventhead"
spry:sort="Title">Title</th>
<th width="189" class="eventhead"
spry:sort="Venue">Venue</th>
</tr>
<tr spry:repeat="ds2" spry:setrow="ds2">
<td height="53" class="event">{Date2}<span
class="eventhide">{Date1}</span></td>
<td class="event">{Type}</td>
<td class="event">{Title}</td>
<td class="event">{Venue}</td>
</tr>
</table>
</div>
</div>
It seems to be working for the moment... -
What should i put in Schme while creating Data server for XML
I am new to XML and ODI also.
I was trying to create a data server for XML technology.
I don't know what should i specify as a schmea in JDBC URL.
e.g. jdbc:snps:xml?f=../demo/xml/1/file.xml&ro=false&ldoc=true&case_sens=true&s=LEO_FIZ&dod=true
here schema is LEO_FIZ, so my doubts is LEO_FIZ is a database schema or what ??
Please help me out.The schema referred to here is going to be used by the XML driver for the instantiation of the temporary schema used for the xml data. It can be any name, I recommend you keep it short, as if you use an external database for the XML data instantiation it is used as a part of the "table" names.
-
Error of Creating Data Server for XML
Hi all,
When I want to create a new data server for XML in ODI, the error occur.
error information:
connection failed
java.sql.SQLException: Unexpected token: EMP_TABLE in statement [create EMP_TABLE]
My JDBC url is: jdbc:snps:xml?f=../demo/xml/MOP/MOPEMP.xml&rt=Export&ro=false&case_sens=true&s=EMP
It seems that the error is caused by the schema "EMP". But when I changed the name of schema, the error still occur...
Could you give me some advices about this?
Thanks&Regards
YanHi,
Thans for your reply.
This is the DTD for my xmldoc.
<!ELEMENT Data (Department+)>
<!ELEMENT EmployeeID (#PCDATA)>
<!ATTLIST EmployeeID col (EMPID) #IMPLIED>
<!ELEMENT Education (EmployeeID, Sequence, Dgree)>
<!ATTLIST Education table NMTOKEN #IMPLIED>
<!ELEMENT Employee (EmployeeName, EmployeeID, DepartmentID, Education*)>
<!ATTLIST Employee table NMTOKEN #IMPLIED>
<!ELEMENT EmployeeName (#PCDATA)>
<!ATTLIST EmployeeName col NMTOKEN #IMPLIED>
<!ELEMENT DepartName (#PCDATA)>
<!ATTLIST DepartName col NMTOKEN #IMPLIED>
<!ELEMENT Table (Column+)>
<!ATTLIST Table importType NMTOKEN #IMPLIED>
<!ATTLIST Table parentTable NMTOKEN #IMPLIED>
<!ATTLIST Table tag NMTOKEN #IMPLIED>
<!ATTLIST Table columns NMTOKEN #IMPLIED>
<!ATTLIST Table name NMTOKEN #IMPLIED>
<!ELEMENT DepartID (#PCDATA)>
<!ATTLIST DepartID col NMTOKEN #IMPLIED>
<!ELEMENT MetaData (Table+)>
<!ELEMENT Sequence (#PCDATA)>
<!ATTLIST Sequence col NMTOKEN #IMPLIED>
<!ELEMENT Dgree (#PCDATA)>
<!ATTLIST Dgree col NMTOKEN #IMPLIED>
<!ELEMENT Export (MetaData, Data)>
<!ELEMENT DepartmentID (#PCDATA)>
<!ATTLIST DepartmentID col NMTOKEN #IMPLIED>
<!ELEMENT Column (#PCDATA)>
<!ATTLIST Column deleteKey NMTOKEN #IMPLIED>
<!ATTLIST Column isKey NMTOKEN #IMPLIED>
<!ELEMENT Department (DepartName, DepartID, Employee+)>
<!ATTLIST Department table NMTOKEN #IMPLIED>
Thanks again!
Yan -
Issue in creating data server for xml in ODI
Hi,
I have a XMl which has a size around 95 MB. When i tried to create data server in ODI for this xml file.
I encounter below error,
"oracle.odi.jdbc.datasource.ConnectionTimeoutException: A login timeout occured while connecting to the database
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.doGetConnection(LoginTimeoutDatasourceAdapter.java:117)
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.getConnection(LoginTimeoutDatasourceAdapter.java:62)
at com.sunopsis.sql.SnpsConnection.testConnection(SnpsConnection.java:1125)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.getLocalConnect(SnpsDialogTestConnet.java:163)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.access$4(SnpsDialogTestConnet.java:159)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet$4.doInBackground(SnpsDialogTestConnet.java:520)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet$4.doInBackground(SnpsDialogTestConnet.java:1)
at oracle.odi.ui.framework.AbsUIRunnableTask.run(AbsUIRunnableTask.java:258)
at oracle.ide.dialogs.ProgressBar.run(ProgressBar.java:656)
at java.lang.Thread.run(Thread.java:662)"
Kindly let me know what should i do for resolving the error.
Thanks and Regards,
Ida Jebakirubai S.Yes Phil i am able to create a data server for xml files which are of smaller in size(in KB). And i can use the files in the interface as well.
When i using this large file only i am getting this error.
Please suggest.
Thanks and Regards,
Ida. -
Date formats for SQL statements used by recordset object
Hi,
Date formatting appears to be quite problematic for Business One. I did a forum search for date issues and I don't think I saw any of them with an "answered" status. I have an issue with formatting a date for the creation of an SQL statement that the DI sends to SQL Server 2005. I need to format a date so that the localization parameters don't matter for either the client machine or SQL Server's machine. We don't have a problem as long as our machines are localized as USA.
I have PL 22 and I have a form - ours - where I use the Today() function to fill a date field. So this is a date that is not entered by the user. The result of this function is consistent with the localization parameters on my machine. We have two other date fields on the form where the user must type in the date.
As a test, I changed my machine to the UK parameters. I then set up the language parameters of Business One for English(United Kingdom). I changed the date format specifications in Business One so that its format is dd/mm/yy. I then brought up the form and the field that is formatted by the above function arrived in the form's field as dd/mm/yy. I then typed in the two other dates in the same format and added the record to the database. The form's table is user-defined.
I dismissed the form then brought it back up loaded with the new record. The date that was entered by the function appeared in USA format (mm/dd/yy). The dates that were typed in appeared in the Business One format (dd/mm/yy). This of course is not consistent.
When I looked at what got into the database, the formats were the opposite. Weird! To make matters really confusing, I run an SQL statement within SQL Server Mgt Studio, and use the WHERE clause to filter on the date that was based on the function. It didnt matter what format I used for the WHERE clause, the record came up. Does anyone have any idea about how I can ensure that I always use the correct date format for SQL statements passed by Business One to SQL Server regardless of where in the world the application is being run?
Thanks,
MikeIan,
Here's what I'm concerned about: Im using the date in a WHERE clause.
Assume the date is Aug 3, 2007.
"SELECT * FROM Table WHERE StartDate > 8/3/2007"
OR
"SELECT * FROM Table WHERE StartDate > 3/8/2007"
If the client machine is set up as USA, the today function will provide the date as formatted in the first query. If the database server is setup as lets say the UK, I believe that SQL Server query parser will interpret the date as Mar 8, 2007.
If the client machine is set up as UK, the today function will provide the date as formatted in the second query. If the database server is setup as lets say USA, I believe that SQL Server query parser will also interpret the date as Mar 8, 2007.
In both cases it would be wrong.
I know I could use the DATEPART function to get the three parts and this will make the code indifferent to the localization specs of the client machine. I need to then be able to concatenate those date parts for the WHERE clause so that the localization specifications of the database server dont matter.
Thanks,
Mike -
Date Format for the input Variable
Hi all,
I got an issue with Date format we enter in the input variable screen for the BEx Analyzer.
We have given a format of MM/DD/YYYY. But when the users accessed the report, it is not taking the format of the variable i.e MM/DD/YYYY but it is taking the format of the users system.
If the user's system format is DD/MM/YYYY, it is accepting the input inthe same format only.
Why this strange behaviour?
My questions are
Is the input for BEx system specific? or variable specific?
Rgrds
KumarHi,
I think it is user specific... you can maintain the date format for user ....
Go to SU01 transaction or.. Go to SYSTEM -> User Profile -> Own data
Here in defaults tab you can see the date formet for user...
Hope this helps...
Thanks,
Vikrant Mahajan -
Configuring date format in Oracle 8.1.7
I have just unloaded records from tables into an sql script file with insert statements. However, the date format for the records that I have unloaded is MM/DD/YYYY. When I try to run this sql script, oracle gives an error, saying it's not a valid month.
Oracle date format is DD-MMM-YY. How can I change the date format in oracle, so that I could insert these records in?If your script does not have explicit TO_DATE conversions (which it should, by the way), like:
insert into t values (to_date('11/21/2002', 'mm/dd/yyyy'));then you can set the default date format to match the format in your script. So, if your script looks like:
insert into t values ('11/21/2002');then:
alter session set nls_date_format = 'mm/dd/yyyy';prior to running the script. -
To accept all date formats for variables
Hi,
I am getting a vadidation message on refresh of a query on entering European date format in the selection criteria "Please enter value in permitted format for variable XXXX"
I need date to accept all date formats for variables to execute query.
Currently US date format has been accomodated, On entering European date format i get the above validation message.
Please suggest how do i supress this validation message or any other thoughts on the same.
If anyone experienced the same before or applied any notes plz send the SAP Note number for the same. I am currently on BW 3.5.
Message was edited by:
tyson mtyson,
why dont you control the date display through the user creation / user details option - then your date entries should sort themselves out.
Arun
Maybe you are looking for
-
How to receive emails on both, icloud mail and hotmail
Hello I use my hotmail account as my Apple ID (since im not able to use my icloud account(@me), and to only have 1 account for everything on Apple), and i use my icloud account (@me) for Mail. When i receive mails from especially Apple (for example,
-
Declaring array of T[] - possible bug?
See the following code: class A {} class B {} public class Test { public static void main(String[] args) { A a = null; foo(a); public static <T> void foo(T a) { T[] t = (T[]) new Object[10]; Object[]
-
When trying to open subtopics on Safari browser hangs and colored wheel comes on?
-
Problems after an "erase and install"
Hi, I recently had problems with my mac and i needed to do an "erase and install" with the original Mac OS cd. Perhaps, before loosing all of my data, i saved it on an other macbook. When i re-install my Mac Os software and all of my data (pictures i
-
Lenovo IdeaCenter A730 takes hours to boot
i bought my pc and after when shipped i noticed that when i switch to hdmi the computer works well and when i switch to PC the hard drive indicator light just keeps on blinking and the LED light goes off and its just blank .. However i still cannot e