Parsing date with SimpleDateFormat

by vincent.gann...@gmail.com » Sat, 28 Mar 2009 01:39:54 GMT


Sponsored Links
 Hi all,

I'm trying to parse the following date string "Fri, 12 Jan 2007
10:00:00 +0100" using SimpleDateFormat. Here is my code :

Date date;
String pubDate = "Fri, 12 Jan 2007 10:00:00 +0100";
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MM yyyy
HH:mm:ss zzz");
try
{
    date = format.parse(pubDate);
}
catch(ParseException e) { }

This code raises the ParseException instead of returning the
corresponding date object.

I tried a huge amount of other date formats to create the
SimpleDateFormat but none has worked.

Any guess? Thanks.
--~--~---------~--~----~------------~-------~--~----~



Parsing date with SimpleDateFormat

by Mike Collins » Tue, 31 Mar 2009 05:37:44 GMT


 my dates come in looking like this  "2004-08-04T19:09:02.768Z"

and I parse them like this

SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-
dd'T'HH:mm:ss'.000Z'");
dateFormater.setTimeZone(TimeZone.getTimeZone("GMT"));
Date d = dateFormater.parse(s);

Try creating a Date object and making a string out of it via the date
format,
if what you get is what you expect for input you should be ok, if not
something
has to be adjusted.

  mike


On Mar 27, 10:39am, "vincent.gann...@gmail.com"


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Question Regarding the Background Menu

Hi there,

I have a GUI question and hope someone can help me out.

I am trying to make a GUI where I have 3 buttons ( start, about,
exit). What I need is to have a background behind these buttons. For
instance Xgalaga game for android. When you start the game there are 3
buttons and behind them is a background.

in my layout I have a main.xml that has ( LinearLayout, and 3
buttons). I tried to add (@drawable/mybackgorundimage) to background
section of LinearLayout (). Well it works but the image is stretched
out and I know this is not a right way.

Some Extra Questions that came to my mind also:

How many ways are possible to this?

What if the background is an animation?

What is the most efficient way to do this?


I would appreciate if someone provide me with a sample code.


Thanks,




--~--~---------~--~----~------------~-------~--~----~

2. Multitouch API for the Hero ??

Hi all,

The htc hero has multitouch capabilities in the browser and in the
picture gallery, but i cannot find any ressources on how to use it in
my own application.

Can someone point me in the right direction ?

Thanks.

--~--~---------~--~----~------------~-------~--~----~

3. How to get android to show my IME in the input method pop-up menu?

4. is it possible to get data from contacts and wirte back?

5. Inserting Images in Text Field along with the Text

6. read csv file

7. Read CID of SD card (MMC)