Thanks Kostya I think this one is better. Thanks once again. On Dec 27, 12:39 pm, Kostya Vasilyev <kmans...@gmail.com> wrote: > Kris & Pramod, > > With all due respect, there is a much easier way. > > Java date/time stamps are internally represented by "long" values, the > value being the number of milliseconds since Jan. 1, 1970 GMT. > > SQLite natively supports long (64-bit) interger values (use INTEGER data > type). > > So, for storing date/time stamp, call "long milliseconds = > Date.getTime()" and store the long integer value in the database. > > When retrieving, get the long integer from the database, then construct > "new Date(long milliseconds)". > > This has two advantages: > > - No text parsing or formatting necessary, smaller chance of bugs > > - Ability to sort or select before / after a certain date/time value > when doing SELECT > > Hope this helps. > -- Kostya > > 27.12.2010 10:06, Kristopher Micinski пишет: > > > > >http://sberka.blogspot.com/2009/07/date-time-sqlite-and-android.html > > > That blog post should point you in the right direction. > > > What you may really want to know is how SQLite handles date and time. > > > From what I've encountered there is no "native" date/time handling in > > SQLite, but you can simply store dates / times in a textual > > representation. The following articles may help give some insight: > > >http://stackoverflow.com/questions/4248064/delphi-sqlite-date-time-fo... > > >http://www.sqlite.org/lang_datefunc.html > > > Typically what you will do is create some database implemented via a > > content provider or just database handler (see the many, many > > tutorials on how to do this) and create a table for storing your > > relevant information. For example, I have a "contents" table, where > > one of the columns is the date an article was published. Now the only > > thing you have to figure out is the marshaling. > > > Thanks, > > Kris Micinski > > > On Mon, Dec 27, 2010 at 1:21 AM, pramod.deore<deore.pramo...@gmail.com> > > wrote: > >> Hi everyone, > >> In my application I have 2 buttons one for DatePickerand > >> one for Timepicker. Date piker gives me date in this format - > >> 12-27-2010 and time in - 11:48. Now I want to create table to store > >> these values. How to store date and time in android database? > >> Thanks. > > >> -- > >> You received this message because you are subscribed to the Google > >> Groups "Android Developers" group. > >> To post to this group, send email to android-developers@googlegroups.com > >> To unsubscribe from this group, send email to > >> android-developers+unsubscr...@googlegroups.com > >> For more options, visit this group at > >>http://groups.google.com/group/android-developers?hl=en > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en