Be very, very, VERY careful about storing date and time information in
a textual format.

There are boundary conditions, timezone issues, leap-year issues,
skipped-leap-year-issues, leap seconds, and finally, localization
issues, which can all reach out and bite you in ways you may not
consider.

Generally, the best option is to not worry about all this, and (as
Kostya rightly points out) use the system-provided utilities for
interpreting dates (if you receive them as text), or work entirely
with longs and never deal with text at all except when displaying to
the user (with proper consideration of timezone and localization).

Otherwise, you're taking on a considerable coding and testing burden
AND a good deal of risk.

The only downside is it makes examining stored date/time data much
more difficult, but you can write a little calculator to do this.

Java and Javascript date formats (and pretty much everybody else) use
seconds since 00:00 January 1, 1970 UTC as their representation, so
you can make yourself (or probably find pre-made) a little web page
that converts them for you.

On Dec 26, 11:06 pm, Kristopher Micinski <[email protected]>
wrote:
> 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

-- 
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

Reply via email to