function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VPVP 

Getting dates/times

Using enterprise wsdl, I am getting the account and opportunity object xmls. The dates-times in those xmls show up as:


1118442218000


So is this the date or the date-time or only time. In either case, how can I convert it into a standard date-time format?
SuperfellSuperfell
using the entprise WSDL, the returned objects are strongly typed, the property should have a DateTime type.
VPVP

Thanks.

But the datetime value in

< createdDate >< time >1118442218000< /time >< /createdDate >

seems to be in a codified format. From the salesforce account page, I see that it corresponds to the date time 6/10/2005 3:23 PM. How can I convert the above value to this format?

SuperfellSuperfell
which API are you using, that's not the enterprise WSDL (what's the URL that you're request is going to)
SuperfellSuperfell
can you post a capture of the complete response XML, it shouldn't look like that.
VPVP

Sure - here it is...

<com.sforce.soap.enterprise.sobject.Account>
  <accountNumber>CD451796</accountNumber>
  <active____c>Yes</active____c>
  <annualRevenue>1.39E8</annualRevenue>
  <billingCity>Austin</billingCity>
  <billingState>TX</billingState>
  <billingStreet>312 Constitution Place
Austin, TX 78767
USA</billingStreet>
  <createdById>00530000000foHYAAY</createdById>
  <createdDate>
    <time>1118442218000</time>
  </createdDate>
  <customerPriority____c>Medium</customerPriority____c>
  <description>Edge, founded in 1998, is a start-up based in Austin, TX. The company designs and manufactures a device to convert music from one digital format to another. Edge sells its product through retailers and its own website.</description>
  <fax>(512) 757-9000</fax>
  <industry>Electronics</industry>
  <lastModifiedById>00530000000foHYAAY</lastModifiedById>
  <lastModifiedDate>
    <time>1118442218000</time>
  </lastModifiedDate>
  <name>Edge Communications</name>
  <numberOfEmployees>1000</numberOfEmployees>
  <numberofLocations____c>2.0</numberofLocations____c>
  <ownerId>00530000000foHYAAY</ownerId>
  <ownership>Public</ownership>
  <phone>(512) 757-6000</phone>
  <rating>Hot</rating>
  <SLAExpirationDate____c>2005-08-22 00:00:00.0 PDT</SLAExpirationDate____c>
  <SLASerialNumber____c>2657</SLASerialNumber____c>
  <SLA____c>Silver</SLA____c>
  <shippingStreet>312 Constitution Place
Austin, TX 78767
USA</shippingStreet>
  <sic>6576</sic>
  <systemModstamp>
    <time>1118442218000</time>
  </systemModstamp>
  <tickerSymbol>EDGE</tickerSymbol>
  <type>Customer - Direct</type>
  <upsellOpportunity____c>Maybe</upsellOpportunity____c>
  <website>http://edgecomm.com</website>
  <____hashCodeCalc>false</____hashCodeCalc>
  <id>00130000006Xo4MAAS</id>
  <____hashCodeCalc defined-in="com.sforce.soap.enterprise.sobject.SObject">false</____hashCodeCalc>
</com.sforce.soap.enterprise.sobject.Account>

SuperfellSuperfell
No, an actual capture of the entire HTTP response, not what your soap stack decided it was.
SuperfellSuperfell
For example, here's one i just captured with SOAPScope

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<queryResponse xmlns="urn:partner.soap.sforce.com">
<result>
<done>true</done>
<queryLocator xsi:nil="true"/>
<records xsi:type="sf:sObject" xmlns:sf="urn:sobject.partner.soap.sforce.com">
<sf:type>Account</sf:type>
<sf:Id>00130000005NGoOAAW</sf:Id>
<sf:AccountNumber xsi:nil="true"/>
<sf:Active__c xsi:nil="true"/>
<sf:AnnualRevenue xsi:nil="true"/>
<sf:BillingCity>San Francisco</sf:BillingCity>
<sf:BillingCountry xsi:nil="true"/>
<sf:BillingPostalCode>94105</sf:BillingPostalCode>
<sf:BillingState>CA</sf:BillingState>
<sf:BillingStreet>XHCWzEZdvb</sf:BillingStreet>
<sf:CreatedById>00530000000d6TVAAY</sf:CreatedById>
<sf:CreatedDate>2005-04-13T18:15:54.000Z</sf:CreatedDate>
<sf:CurrencyIsoCode>USD</sf:CurrencyIsoCode>
<sf:CustomerPriority__c xsi:nil="true"/>
<sfescription>a description would go here instead of this text</sfescription>
<sf:Fax>415 415 4155</sf:Fax>
<sf:Id>00130000005NGoOAAW</sf:Id>
<sf:Industry xsi:nil="true"/>
<sf:LastModifiedById>00530000000d6TVAAY</sf:LastModifiedById>
<sf:LastModifiedDate>2005-04-13T18:15:54.000Z</sf:LastModifiedDate>
<sf:Name>EfQOKNalreXzUlg</sf:Name>
<sf:NumberOfEmployees xsi:nil="true"/>
<sf:NumberofLocations__c xsi:nil="true"/>
<sfwnerId>00530000000d6TVAAY</sfwnerId>
<sfwnership xsi:nil="true"/>
<sfarentId xsi:nil="true"/>
<sfhone>415 415 4115</sfhone>
<sf:Rating xsi:nil="true"/>
<sf:ShippingCity>San Francisco</sf:ShippingCity>
<sf:ShippingCountry xsi:nil="true"/>
<sf:ShippingPostalCode>94105</sf:ShippingPostalCode>
<sf:ShippingState>CA</sf:ShippingState>
<sf:ShippingStreet>DAWtjFNLvG</sf:ShippingStreet>
<sf:Sic xsi:nil="true"/>
<sf:Site xsi:nil="true"/>
<sf:SLA__c xsi:nil="true"/>
<sf:SLAExpirationDate__c xsi:nil="true"/>
<sf:SLASerialNumber__c xsi:nil="true"/>
<sf:SystemModstamp>2005-04-13T18:15:54.000Z</sf:SystemModstamp>
<sf:TickerSymbol xsi:nil="true"/>
<sf:Type xsi:nil="true"/>
<sf:UpsellOpportunity__c xsi:nil="true"/>
<sf:Website>http://www.sforce.com</sf:Website>
</records>
<size>1</size>
</result>
</queryResponse>
</soapenv:Body>
</soapenv:Envelope>

Message Edited by SimonF on 08-19-2005 01:14 PM

VPVP
I tried viewing msg in SOAPScope using SSL forwarding. But I can see only the login request-reply message and not the other messages. I have set ssconfig as "ssconfig -s 8200,https://na1-api.salesforce.com". Do the subsequent interactions for getting account and opportunity data go on a different url?
SuperfellSuperfell
post login calls goto the serverUrl returned in the login call, what i normally do is switch out to http from https so the sniffer can pickup the traffic.
VPVP
The surprising thing is that https://na1-api.salesforce.com is the postlogin bind address. So I had ssconfig setup for that. So now I soapscope should not pick up the login call but should pick up all postlogin calls. Even after that it still picks up only login.
VPVP
This is the soap message that I get from the debug output in eclipse:




pportunity" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
00630000002XDVoAAO
00130000006Xo4WAAS
85000.0
2005-08-22
00530000000foHYAAY
2005-06-10T22:24:26.000Z
Honda
eliveryInstallationStatus__c>CompletedeliveryInstallationStatus__c>
85000.0
Closed
false
true
false
true
00530000000foHYAAY
2005-06-10T22:24:26.000Z
Partner Referral
Honda
GenePoint Standby Generator
rderNumber__c>908676rderNumber__c>
wnerId>00530000000foHYAAYwnerId>
robability>100.0robability>
Closed Won
2005-06-10T22:24:26.000Z
830150301420
New Customer





So the date does seem to be correct here.
SuperfellSuperfell
so, what soap stack are you using ?
VPVP
I am using axis 1.2.
VPVP
Some dates I am getting correctly while others not so. Is the difference due to the difference in the types of dates in the wsdl - the ones that are xsd:dateTime are coming out as a number and those that are xsd:date are coming out correctly.
SuperfellSuperfell
I'd either switch back to Axis 1.1, or try Axis 1.2.1
VPVP
I tried axis 1.1 and it gives same output as shown below: 00130000002Pa37AAC 85000.0 2004-09-10 00:00:00.0 PDT 00530000000d9buAAA 1088499889000 Honda Completed 85000.0 Closed false true false true 00530000000d9buAAA 1088499889000 Partner Referral Honda GenePoint Standby Generator 908676 00530000000d9buAAA 100.0 Closed Won 1088513633000 830150301420 New Customer false 00630000001DTBrAAO false Do I have to change any date deserializers to correct this?
SuperfellSuperfell
I've never needed to. I think you're taking a wrong step somewhere along the line, have you walked through the quick starts ?
VPVP
I will review the quick starts again as you suggest. But what beats me is that some of the dates are coming back properly (the xsd:date ones) and only this defined as xsd:datetime are coming out incorrectly.
VPVP
Going a little deeper into this, I found that sforce Opportunity object generated by WSDL2Java has data type as java.util.Calendar for those dates defined in WSDL as xsd:datetime. This conforms to the JAXRPC spec. So I presume most people are getting date in the same format. So now what I need to do is to convert from Calendar to a regular date.
VPVP
I am able to convert from the long date returned to a regular datetime format. But the dates returned from SF do not include timezone and that results in improper conversion. Is there particular reason for omitting the timezone? What is the implied timezone that I should use for properly converting from the date expressed in millisecs to the regular date-time format?
SuperfellSuperfell
Tz is included, from the sample i posted earlier, you see
2005-08-08T13:00:00Z
the Z means UTC (aka GMT)

I think you'll find that getTime on the calendar instance return you a java.util.Date.
VPVP
Thanks - Java's simpledateformat does not seem to recognize Z as a valid timezone code. I had to replace Z with GMT for it to take it as GMT time.
SuperfellSuperfell
I really don't understand why you're having togo these lengths. the generated proxy returns a Calendar instance, that has a getTime() methods which returns the same date/time as a java.util.Date.
VPVP
Reason is that I am using an xml serializer and a transformer to convert the data from SF format to our system format - in the process the opportunity object from SF get converted into an xml that represents the time in milliseconds - which we need to convert into datetime format for our system purposes.
VPVP
Thanks Simon for persisting thru' this. I am able to get the data correctly from SF format to our own.