Jump to content

Customize the date format?


Recommended Posts

Posted

I would like to have my date format like this..: dd.MM.yyyy, is there really no way to accomplish this?

Regards,

BTJ

Guest nrkabul
Posted
I would like to have my date format like this..: dd.MM.yyyy, is there really no way to accomplish this?

I had the same problem (wanted yyyy-MM-dd), and ended up writing an app to set it for me - if you want the source, let me know.

Posted
I had the same problem (wanted yyyy-MM-dd), and ended up writing an app to set it for me - if you want the source, let me know.

That would be nice, if you don't mind... :)

BTJ

Guest nrkabul
Posted
That would be nice, if you don't mind... :)

NP, I'll dig it up tonight (at work now).

Guest nrkabul
Posted

Here's the project. I've used the Netbeans plugin, so I don't really know if this compiles from the command line with only the SDK installed, sorry.

The APK in the dist directory will set the date format to "yyyy-MM-dd" using

Settings.System.putString(getContentResolver(), Settings.System.DATE_FORMAT, "yyyy-MM-dd");

Be very careful when changing the format string - I just managed to get my emulator stuck in a boot loop after setting an invalid format, and had to wipe it. Not sure what would happen on a real device, but probably nothing pretty. If "new SimpleDateFormat( <format> )" is happy, you should be too.

As is usual, I can't take responsibility for anyone's phone crashing, turning into a pink parsnip or more realistically boot-looping forever.

Good luck :)

DateFormatSetter.zip

Guest nrkabul
Posted

To make this at least possible to use for non-developers, I've added a text box where you can change the format before setting it. Before updating the setting, I try to create a SimpleDateFormat based on the supplied format string. If the constructor excepts, you get an error message and the setting won't be changed.

This does not mean that I catch all potential problems (I hope I do, but I probably don't). Be careful.

The dist directory in the attached zip contains the compiled APK.

DateFormatSetter2.zip

Guest clarkEEE1
Posted

You can change the date format anyway all you need to do is settings, date and time then scroll down to select date format.

Posted
You can change the date format anyway all you need to do is settings, date and time then scroll down to select date format.

Yes, I can.. But the problem is that the date format I want is not listed there....

BTJ

Posted (edited)
Here's the project. I've used the Netbeans plugin, so I don't really know if this compiles from the command line with only the SDK installed, sorry.

The APK in the dist directory will set the date format to "yyyy-MM-dd" using

Settings.System.putString(getContentResolver(), Settings.System.DATE_FORMAT, "yyyy-MM-dd");

Be very careful when changing the format string - I just managed to get my emulator stuck in a boot loop after setting an invalid format, and had to wipe it. Not sure what would happen on a real device, but probably nothing pretty. If "new SimpleDateFormat( <format> )" is happy, you should be too.

As is usual, I can't take responsibility for anyone's phone crashing, turning into a pink parsnip or more realistically boot-looping forever.

Good luck :)

DateFormatSetter.zip

Thx, I'll take a look at it... :D

Edit: Aaah, so that's all you do... I guess is should be possible to change som file on the android to change this format but I will try this method first...

BTJ

Edited by BTJ
  • 1 month later...
Posted

Hi,

I'm looking for a date format something like 30-Dec-2009. Is that possible to set using the DateFormatSetter that you posted?

Thanks for your help!

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.