Well, you can store time as date-time modulo 24 hours -- fits easily in 32 bits. Otherwise, probably some sort of hours/minutes/seconds triplet (or just hours/minutes).
On Dec 27, 7:17 am, "pramod.deore" <[email protected]> wrote: > Ok, Now I have stored date in miliseconds format. from this I can get > year, month and date(I can also get time from this). But how to store > time? Because there are 2 buttons for user to select using first > button user select the date on which he wants to on particular switch > and second button for the time to on the switch. Should I store this > time in normal int format? > > On Dec 27, 5:11 pm, "pramod.deore" <[email protected]> wrote: > > > Thanks Bob and Federico. > > > On Dec 27, 4:59 pm, Federico Paolinelli <[email protected]> wrote: > > > > I do agree with this approach :-) > > > > On 27 Dic, 08:39, Kostya Vasilyev <[email protected]> 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<[email protected]> 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 > > > > >> [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-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 [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-developers?hl=en

