How do I can parse this date 2018-01-09T11:11:02.0+03:00
to dd.MM.yyyy hh:mm
format in Android?
And what does T
between 09
and 11
mean?
Thanks.
I don't know how the back-end developer got this format. I am using Java.
How do I can parse this date 2018-01-09T11:11:02.0+03:00
to dd.MM.yyyy hh:mm
format in Android?
And what does T
between 09
and 11
mean?
Thanks.
I don't know how the back-end developer got this format. I am using Java.
As you're interested in a Date
object and the JSON occurs to me to be a unix timestamp.
Therefore I'd recommend you the Date(long milliseconds) constructor :)
private Date JSONTarihConvert(String tarih) throws ParseException{
long timestamp = getTimeStampFromTarih(tarih);
return new Date(timestamp);
}
Where getTimeStampFromTarih
extracts the milliseconds before the occurrence of "+"
Do not parse your date into the Arabic it will give you error alwayz besides try as below by setting the Locale ENGLISH only.
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
The time seems to also have the timezone there so I would do something like this:
String timeString = json.substring(json.indexOf("(") + 1, json.indexOf(")"));
String[] timeSegments = timeString.split("\+");
// May have to handle negative timezones
int timeZoneOffSet = Integer.valueOf(timeSegments[1]) * 36000; // (("0100" / 100) * 3600 * 1000)
int millis = Integer.valueOf(timeSegments[0]);
Date time = new Date(millis + timeZoneOffSet);
I tried it with 30/01/2010
SUBSTITUTE(A1,".","/")
and then I put in
=TEXT(B1, "yyyy-mm-dd").
The result was expected.
I suspect the issue is the cell you are doing this too is not in date format.
For example, if I change my value to 30.01.2010 then the value is then duplicated (in the same manner you describe)
Or, you could keep it as
=TEXT(A1, "yyyy-mm-dd")
And update all the . to / with a quick macro
Option Explicit
Sub ReplaceDate()
Dim row As Integer
row = 1
Do While (Range("A" & row).Value <> "")
Dim val As String
val = Range("A" & row).Value
Dim i As Integer
Dim result As String
result = ""
Dim spl() As String
spl = Split(val, ".")
If (UBound(spl) > 0) Then
For i = 0 To Len(val)
Dim r As String
result = result & Replace(Mid(val, i + 1, 1), ".", "/")
Next i
End If
If result <> "" Then
Range("A" & row).NumberFormat = "@"
Range("A" & row).Value = result
End If
row = row + 1
Loop
End Sub
How do I add VBA in MS Office?
If you are using java, you can use
SimpeDateFormat
with patterns:The output is :
EDIT : Thanks to @OleV.V., for API > 26, or using ThreeTenABP we can use
DateTimeFormatter, we can do something like that