The Answer by Shoustin is correct. Here's more related to the context of the Question.
Count-from-epoch
The 1503952200000
is perhaps a count of milliseconds since the epoch reference date of 1970-01-01T00:00:00Z
.
Offset-from-UTC
The +0330
looks like an offset-from-UTC. The problem is that we cannot tell if that means the count-from-epoch is in UTC and we should adjust three and a half hours, or if the count-from-epoch has already been adjusted by three-and-a-half hours. I will go with the former.
This is a terrible format for communicating date-time values as text. If you have any control, change to using standard ISO 8601 formatted strings.
long count = Long.parseLong( "1503952200000" ) ;
Instant instant = Instant.ofEpochMilli( count ) ;
ZoneOffset offset = ZoneOffset.of( "+0330" ) ;
OffsetDateTime odt = instant.atOffset( offset ) ;
Duration
As Shoustin explained, the "PT15H30M" is a span-of-time of fifteen hours and thirty minutes — not a time-of-day.
Duration d = Duration.parse( "PT15H30M" ) ;
You can add that to your OffsetDateTime
if you want to arrive at another point on the timeline.
OffsetDateTime odtLater = odt.plus( d ) ;
See this code run live at IdeOne.com.
count: 1503952200000
instant.toString(): 2017-08-28T20:30:00Z
odt.toString(): 2017-08-29T00:00+03:30
odtLater.toString(): 2017-08-29T15:30+03:30
Invalid Iran time?
By the way, I am confused by the offset of three and a half hours. Looking at the list of current time zones, the only case of a +03:30 offset is by Asia/Tehran
time zone. But that is for standard time, not the Daylight Saving Time (DST) in effect during the given August date. For the date of 2017-08-29, there is no offset of +03:30 being used anywhere on Earth.
So I suspect you have been given faulty data. I suspect the count-from-epoch was calculated separately, and the offset was glued on after-the-fact. This is an example of why your input string format is such a poor design. Stick to ISO 8601, and avoid tracking time as a count-from-epoch.
And use time zone whenever it is known, rather than a mere offset-from-UTC. An offset is only a number of hours and minutes. A time zone is a history of past, present, and future offsets in use at various points in time by a particular region. The ZonedDateTime::toString
method wisely extends the ISO 8601 to append the zone name in square brackets.
ZonedDateTime zdt = ZonedDateTime.parse( "2017-08-29T15:30+04:30[Asia/Tehran]" ) ;
String output = zdt.toString() ;
2017-08-29T15:30+04:30[Asia/Tehran]
Tip: Generally best to exchange date-time data in UTC, as Instant
objects or the ISO 8601 equivalent.