That page also said not to use native methods for trivial computation.
In my experience the Java Calendar and Date objects are expensive and
memory hungry. Avoid them, including their DateFormatters, whenever
possible. That being said, it probably shouldn't matter much unless
you are performing many calculations in a loop. So the only real time
to consider avoiding them, I guess, is when you are investigating
performance problems.
On Mar 6, 6:55 am, Tseng <[email protected]> wrote:
> I wouldn't really use this method to be honest. Even the Android
> Documentation sugest to use native methods, instead of writing your
> own stuff for methods which are already available (i.e. simple date
> formating).
>
> [Use Native 
> Methods]http://developer.android.com/guide/practices/design/performance.html#...
>
> On Mar 6, 1:20 pm, droozen <[email protected]> wrote:
>
> > Sometimes I construct my human readable strings in a separate function
> > by myself, mostly because I imagine it's faster. Something like.
>
> > int iMonth = cal.get(Calendar.MONTH) + 1; // Months from the calendar
> > are offset by one. Add one if you want human readable.
> > int iDay = cal.get(Calendar.DAY_OF_MONTH);
>
> > String month = Integer.toString(iMonth);
> > if(iMonth < 10){
> >     month = "0" + month; // Otherwise, you might get something like
> > 1/1/1900, instead of 01/01/1900
>
> > }
>
> > String day = Integer.toString(iDay);
> > if(iDay < 10){
> >     day = "0" + day;
>
> > }
>
> > String humanReadable = month + "/" + day + "/" cal.get(Calendar.YEAR);
>
> > But really, you should be using SimpleDateFormat, I suppose...
>
> > On Mar 6, 5:55 am, Łukasz Warchoł <[email protected]> wrote:
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to