0

How can I get the same date format in Android. On different devices i have different date format for example:

device 1.

13.03.2017 11:05

device 2.

Sun Mar 13 2017 11:05:00 GTM+0100 (CET)

I try use:

data.toString().split(/[^0-9]+/);

with

new Date(dateNew[2],dateNew[1],dateNew[0],dateNew[3],dateNew[4])

but sometime I have got month: "Jan", "Feb", "Mar" etc.

It is any method to convert date format to same type i JavaScript.

Tazani
  • 39
  • 6
  • You need new SimpleDateFormat("yyyy-mm-dd", Locale.DEFAULT).format(Calender.instance()). Use any format you want, – Dexter Feb 13 '17 at 10:23
  • @Dexter it is available on javascript? – Tazani Feb 13 '17 at 10:33
  • No. For javascript you can use "moment.js" if it is a web app. – Dexter Feb 13 '17 at 10:35
  • The result of *Date.prototype.toString* is defined as being implementation dependent, so no surprise that you get different results in different browsers. See [*Where can I find documentation on formatting a date in JavaScript?*](http://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript?s=1|4.5819) Also checkout [*fecha.js*](https://github.com/taylorhakes/fecha) for parsing and formatting and [*moment.js*](http://momentjs.com) to also do arithmetic. – RobG Feb 13 '17 at 10:42

0 Answers0