Format date to Brazilian format using webservices

Asked

Viewed 436 times

0

How to format a data timestamp for timestamp br. ex.

2015-02-03 15:37:00 para 03/02/2015 15:37:00

Obs: the date is a text

  • Always comes in this pattern?

  • @Diegof, yes. It always comes in this pattern

  • Same string format?

  • Yes. The date always comes from a webservice.

  • I mean, the output(formatted date) you expect has to be the correct string?

1 answer

1


One of the forms can be as below:

    String dataUS = "2015-02-03 15:37:00";

    SimpleDateFormat oldFormat =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat newFormat =  new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    System.out.println(newFormat.format(oldFormat.parse(dataUS)));

Returning:

03/02/2015 15:37:00

See working on IDEONE.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.