How can I save string type into android SQLite datetime field

I've got following string "2013-04-30T00:55:25.855-07:00" from Google blogger feed. I try to save this string to SQLite datetime field as following command

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
initialValues.put(newsdatemodified, dateFormat.format(datemodified));

But I found that data cannot insert into sqlite table and no encounter any errors. Any solution will be appreciated.

Update

When I've tried to use following coding

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date date1 = (Date) dateFormat.parse(entry.updated);

but following this error

05-02 09:56:05.383: E/AndroidRuntime(31634): Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date

Answers


It seems that issue is with the format. May be, you can try using yyyy-MM-dd'T'HH:mm:ss.SSSZ. SSS stands for fractional seconds and Z stands for time zone.

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

Hope it helps else please comment. You can see other formats and try to work around with them by seeing here.


Your format is wrong, it needs to me yyyy-MM-dd'T'HH:mm:ss.SSSZ

as you can see the format you had does not match what the incoming string format was


Need Your Help

XSLT1.0+Schematron: translate instance text XPath values so they can be dynamically evaluated during an XSLT transformation

xml xslt xpath evaluate schematron

I'm using Schematron to validate instance XML documents inside a custom schema aware XML editor (note that Schematron validation is just an XSLT transformation). The instance may contain elements w...

OS Name Variable

variables batch-file operating-system windows-7-x64 placeholder

I would like to run a script where I can get the windows Name and version of the system of all computers running in the company, put it in a text fil. Then make a system variable out of my windows ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.