Android Code Snippet Convert timestamp date to Brasil format

Hi.
here is a simple code to convert a timestamp to Brasil format, easy to modify to another countrys format.
B4X:
Sub Timestamp_Brasileiro(dataTimeStamp As String) As String
    DateTime.DateFormat = "yyyy-MM-dd" : DateTime.TimeFormat = "HH:mm:ss" 'TRANSFORMA DATA DO CEL EM PADRÃO DE BANCO DE DADOS
    Dim dataTempo() As String  = Regex.Split(" ", dataTimeStamp)
    Private ltempo As Long = DateTime.DateTimeParse(dataTempo(0),dataTempo(1))
    DateTime.DateFormat = "dd/MM/yyyy" : DateTime.TimeFormat = "HH:mm" 'VOLTAMOS A DATA PARA O PADRÃO BRASILEIRO
    Return DateTime.Date(ltempo) & " " & DateTime.Time(ltempo)
End Sub

Example of use
B4X:
log(Timestamp_Brasileiro("2018-12-04 12:04:48"))

the result log is
04/12/2018 12:04

;)
 
Top