Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Help with Date and SimpleDateFormat

Reply
Thread Tools

Help with Date and SimpleDateFormat

 
 
Kyote
Guest
Posts: n/a
 
      10-21-2003
On Tue, 21 Oct 2003 17:55:21 +0200, Michael Borgwardt
<(E-Mail Removed)> wrote:

>Kyote wrote:
>>>>>>SimpleDateFormat sdf = new SimpleDateFormat("M/d/yyyy hh:mm");
>>>>>>String dd = sdf.format(param.getTime());
>>>>>>System.out.println(dd);

>>
>>
>>
>> Mike, or anyone, is there a way to show military time instead of
>> a.m./p.m.?

>
>Sure there is, read the friggin' API already!



I did look in the API. I couldn't find it there and I'd really
appreciate it if someone can tell me how to find it there?

But I found it in Websphere's context sensitive help.
I simply use capital H's instead of h.

fwiw I always check the API first. In case you hadn't caught that
particular part of my earlier post, I don't understand the API at ALL.
Well, that's not completely true. I understand very little of it...
In fact if there's any web site anyone knows of that could possibly
help me understand it better I'd REALLY appreciate that.


Thanks for all the help.



-----------
Kyote
 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      10-21-2003
Kyote wrote:

> I did look in the API. I couldn't find it there and I'd really
> appreciate it if someone can tell me how to find it there?
>
> But I found it in Websphere's context sensitive help.
> I simply use capital H's instead of h.


Exactly, and there's a nice clean table in the API doc of
SimpleDateFormate where this is decribed.

> fwiw I always check the API first. In case you hadn't caught that
> particular part of my earlier post, I don't understand the API at ALL.
> Well, that's not completely true. I understand very little of it...
> In fact if there's any web site anyone knows of that could possibly
> help me understand it better I'd REALLY appreciate that.


Why exactly do you have problems understanding it? You definitely
should do everything you can to amend that, understanding the API
docs is an absolutely crucial skill for all but the most trivial
use of Java.

 
Reply With Quote
 
 
 
 
Kyote
Guest
Posts: n/a
 
      10-21-2003
On Tue, 21 Oct 2003 18:24:49 +0200, Michael Borgwardt
<(E-Mail Removed)> wrote:

>Kyote wrote:
>
>> I did look in the API. I couldn't find it there and I'd really
>> appreciate it if someone can tell me how to find it there?
>>
>> But I found it in Websphere's context sensitive help.
>> I simply use capital H's instead of h.

>
>Exactly, and there's a nice clean table in the API doc of
>SimpleDateFormate where this is decribed.


OUCH!!! I see the table now... How I missed it earlier I can't
explain. If I'd have seen it I wouldn't have had to use Websphere to
find it.... After I read your post I went straight to SimpleDateFormat
and started scrolling down to look for the alleged table....
*sniffles* I apologize !! I really did look through the API,
repeatedly....

>> fwiw I always check the API first. In case you hadn't caught that
>> particular part of my earlier post, I don't understand the API at ALL.
>> Well, that's not completely true. I understand very little of it...
>> In fact if there's any web site anyone knows of that could possibly
>> help me understand it better I'd REALLY appreciate that.

>
>Why exactly do you have problems understanding it? You definitely
>should do everything you can to amend that, understanding the API
>docs is an absolutely crucial skill for all but the most trivial
>use of Java.


I would in a heartbeat if I knew how. That's why I was asking for a
url in my last post. I'd love to find out why it is I keep having
trouble with the API.



-----------
Kyote
 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      10-22-2003
Kyote wrote:

>>Why exactly do you have problems understanding it? You definitely
>>should do everything you can to amend that, understanding the API
>>docs is an absolutely crucial skill for all but the most trivial
>>use of Java.

>
>
> I would in a heartbeat if I knew how. That's why I was asking for a
> url in my last post. I'd love to find out why it is I keep having
> trouble with the API.


No URL is going to be able to tell you *why* you have that problem.
The Java API docs are generally considered to be quite well-structures
and helpful.

Again: what problems exactly do you run into when using them? Where
do you look first, where and why do you give up?

 
Reply With Quote
 
Kyote
Guest
Posts: n/a
 
      10-22-2003
On Wed, 22 Oct 2003 11:33:21 +0200, Michael Borgwardt
<(E-Mail Removed)> wrote:

>Kyote wrote:
>
>>>Why exactly do you have problems understanding it? You definitely
>>>should do everything you can to amend that, understanding the API
>>>docs is an absolutely crucial skill for all but the most trivial
>>>use of Java.

>>
>>
>> I would in a heartbeat if I knew how. That's why I was asking for a
>> url in my last post. I'd love to find out why it is I keep having
>> trouble with the API.

>
>No URL is going to be able to tell you *why* you have that problem.
>The Java API docs are generally considered to be quite well-structures
>and helpful.
>
>Again: what problems exactly do you run into when using them?


Misunderstanding for the most part. There are 3 panes (Top Left,
Bottom Left, Right) I think the top left are the packages. The bottom
left are the classes. My trouble comes in the pane on the right.

When I choose say, java.text (top left), SimpleDateFormat (bottom
left), I get the class description to the right. I understand that
much, I think..?? When I click on Method ie

SUMMARY: INNER | FIELD | CONSTR | METHOD

It takes me down to the Method area of the page. In fact, I think I
read the SimpleDateFormat class description in Websphere, so I kept
skipping straight to methods, fields, and constructors, without
scrolling down on the description, in the java API.

The layout of the methods table is what seems to toss me for a spin.
Here's an example:

void applyLocalizedPattern(String pattern)
Apply the given localized pattern string to this date
format.

void

Okay, void is in the left hand column of the table:

applyLocalizedPattern(String pattern)

applyLocalizedPattern(String pattern) is in the right hand along with
a description. I can't for the life of me remember what's what. I
think void is the return type? Not knowing for sure gets me frustrated
rather quickly I'm sorry to say. Not to mention that I'm not too sure
of the right hand column... Is there a help file that explains all of
it in detail? Something I can refer to when I forget, which is likely,
at least at first?

>Where do you look first, where and why do you give up?


I usually give up when I can't understand where to go after looking at
the methods. Well, I will actually look at several methods before
actually giving up. But when I try something from the API that I think
I understand only to get an exception from the attempt, it makes me
think that my understanding of the API is flawed. THAT's when I give
up. But I still keep going back to the API each time I need to look up
something hoping that maybe I had a typographical error.....

Please, feel free to straighten me out. I need to understand the API.

Thank you for any help you can provide.



-----------
Kyote
 
Reply With Quote
 
David Postill
Guest
Posts: n/a
 
      10-22-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <(E-Mail Removed)>, on Wed, 22 Oct 2003
10:33:49 -0500, Kyote <(E-Mail Removed)>
wrote:

<snip />

| I usually give up when I can't understand where to go after looking at
| the methods. Well, I will actually look at several methods before
| actually giving up. But when I try something from the API that I think
| I understand only to get an exception from the attempt, it makes me
| think that my understanding of the API is flawed. THAT's when I give
| up. But I still keep going back to the API each time I need to look up
| something hoping that maybe I had a typographical error.....
|
| Please, feel free to straighten me out. I need to understand the API.
|
| Thank you for any help you can provide.

Have you run through the java tutorial yet?

Well worth doing to increase your general understanding of how java works and
how various bits fit together.


[[http://java.sun.com/docs/books/tutorial/index.html][The Java Tutorial]]

Also try Dick Baldwin's tutorial. There are 3 different ones depending on your
level of understanding.

[[http://www.dickbaldwin.com/tocint.htm][Introductory Java Programming]]
[[http://www.dickbaldwin.com/tocmed.htm][Intermediate Java Programming]]
[[http://www.dickbaldwin.com/tocadv.htm][Advanced Java Programming]]

And if you get stuck on understanding a particular keyword or concept then try
Roedy Greens Java Glossary. Another
excellent resource.

[[http://mindprod.com/jgloss/jgloss.html][mindprod.com]] Java Glossary

Finally there is Peter Lindens' Java Programmers Faq

[[http://www.afu.com/intro.html][Java Programmers]]

And the JGuru FAQs

[[http://www.jguru.com/faq][jguru.com]]

Regards,

<davidp />

- --
David Postill




-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.2 - not licensed for commercial use: www.pgp.com
Comment: Get key from pgpkeys.mit.edu:11370

iQA/AwUBP5a6IHxp7q1nhFwUEQIlnwCgxVwqKVGk3tiXnBTbqHVy1O htlw8AoNHK
kIgdfBfGLuLOc93E3vKkMezg
=+v+F
-----END PGP SIGNATURE-----

 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      10-24-2003
Kyote wrote:
[API docs]
>>Again: what problems exactly do you run into when using them?

[]
> The layout of the methods table is what seems to toss me for a spin.
> Here's an example:
>
> void applyLocalizedPattern(String pattern)
> Apply the given localized pattern string to this date
> format.
>
> void
>
> Okay, void is in the left hand column of the table:
>
> applyLocalizedPattern(String pattern)
>
> applyLocalizedPattern(String pattern) is in the right hand along with
> a description. I can't for the life of me remember what's what. I
> think void is the return type?


What else could it be? I really don't see how this could pose a problem.


> rather quickly I'm sorry to say. Not to mention that I'm not too sure
> of the right hand column... Is there a help file that explains all of
> it in detail? Something I can refer to when I forget, which is likely,
> at least at first?


To me, it was all nearly obvious right from the beginning. It sounds like
you just need to get used to the structure. Maybe it's just confusing to you
because you keep jumping into the middle of huge classe descriptions.
Try browsing through the API docs for some classes that have only
a couple of methods. The structure should be easier to understand there.


>>Where do you look first, where and why do you give up?

>
> I usually give up when I can't understand where to go after looking at
> the methods. Well, I will actually look at several methods before
> actually giving up. But when I try something from the API that I think
> I understand only to get an exception from the attempt, it makes me
> think that my understanding of the API is flawed. THAT's when I give
> up.


OK, that part I can understand. Note that the detailed method descriptions
also often list the exceptions that can be throw, and what the reason would
be. Unfortunately, these descriptions are often missing or incomplete, and
of course the can't cover stuff like NullPointerException or
ArrayIndexOutOfBoundException that can crop up almost everywhere.

In a case where an API library method throws an unexplainable exception,
it can help to look at the source code where the exception is thrown.
The SDK comes with the complete API library source, and a good IDE
should be able to include it so that you can jump directly to it from
the method call in your code. The sources also include the documentation
as JavaDoc comments, and nowadays I rarely look at the HTML docs anymore.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble parsing date/time with SimpleDateFormat Scott Harper Java 2 04-03-2006 04:49 PM
SimpleDateFormat Problem while Parsing Date/time String on Japanese OS shilpa Java 8 09-05-2005 05:17 PM
SimpleDateFormat Help Seb Java 4 12-16-2004 09:14 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Problems Parsing Date string with SimpleDateFormat Bill Angel Java 4 09-28-2003 01:36 PM



Advertisments