I have a date textview. And my textview holds a date string like 2011.09.17. Well I still do want to have that but I also want to add some more user friendly info for some specific dates like today or yesterday. For example if today is 2011.09.17 I want my textview to have value of yesterday instead 2011.09.16 and today instead 2011.09.17.
well I already managed to do this :), but in the ugly way :(. I do this with a lot of ‘if->than’ which is really uglly and what ever I want to add some new rule like if the date is older than one year I want to put string like last year or so…. I really need to add ugly logic.
My question is is there a nicer way to do this ? is there something like design pattern for this ? What is the recommended way to do this ? I am sure that many people have encounter this kind of problems
if there some bather approach than thousand of ifs ? if not thanks any way at least I will stop searching for bather solution
any suggestions , snippet or so will be appreciated
Thanks
I usually use this handy java library for Relative Time formatting. Prety Time Library