Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38676

Re: Overloading methods question

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Overloading methods question
Date 2018-10-29 16:39 -0400
Organization A noiseless patient Spider
Message-ID <pr7r6j$k4l$1@dont-email.me> (permalink)
References (2 earlier) <pqt6v0$e65$1@dont-email.me> <gqboe79efsd$.1p4kudk4cwuxl.dlg@40tude.net> <pr0hef$j4u$1@dont-email.me> <pr1j13$db1$1@dont-email.me> <pr7k6s$35t$1@dont-email.me>

Show all headers | View raw


On 10/29/2018 2:40 PM, Rhino wrote:
> On 2018-10-27 7:43 AM, Eric Sosman wrote:
>> On 10/26/2018 10:10 PM, Rhino wrote:
>>> [...]
>>> Now that I've learned more about the classes and methods available in 
>>> the java.time.* classes, I've realized that I can do practically 
>>> anything I need to do directly in my programs in a single line. [...]
>>> I previously had a method to determine if a date string like 
>>> "2018-10-26" met all the criteria to be a valid ISO date; it was well 
>>> over 100 lines long. [...]
>>
>>      The java.time package arrived with Java 1.8 in 2011.
>>
> I knew they came out in Java 1.8 but I didn't realize it had been around 
> for so long. I basically didn't touch Java - aside with some dabbling 
> with F/X - from around 2012 until recently. I hadn't gotten around to 
> converting to java.time by the point at which I stopped using Java in 2012.
> 
>>      The java.text.DateFormat and java.text.SimpleDateFormat classes
>> have been around since -- well, since "I dunno, but they're described
>> in my Java 1.1 O'Reilly book from 1997."
>>
> Yes, I was using those too, not just Calendar :-)
> 
>>      Maybe you could benefit by spending a little more time reading
>> before starting to code.  "Those who will not learn from Javadoc
>> are condemned to re-implement."
>>
> Indeed, no question about that.
> 
> But it's been fun rewriting those old date routines in favour of the 
> java.time approach :-)

     Maybe I should have been more direct.  Here's another try:

     java.text.SimpleDateFormat::parse can determine whether a String
meets "all the criteria to be a valid ISO date," and has been able to
do so since long before java.time appeared on the scene.  Had you been
aware of this you would not have needed to write your 100+ lines at all.

     You can save yourself lots of time and effort by becoming familiar
with the time and effort others have already spent to smooth your way.
Or you can re-invent yet another wheel ("fewer corners, fewer bumps!").

-- 
esosman@comcast-dot-net.invalid
Eight hundred fourteen days to go.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-24 17:04 -0400
  Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-24 18:56 -0400
  Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-25 10:13 +0200
    Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 15:53 -0400
      Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-25 13:58 -0700
        Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 17:49 -0400
          Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-25 22:29 +0000
            Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 20:08 -0400
              Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 00:37 +0000
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 21:42 -0400
                Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:46 +0200
                Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-26 07:50 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 19:33 +0000
                Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 13:13 -0700
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-26 20:58 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-27 22:36 +0000
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-27 19:38 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-28 10:39 +0000
                Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-28 07:54 -0400
          Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 06:26 -0700
      Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:52 +0200
        Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-26 22:10 -0400
          Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-27 07:43 -0400
            Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:40 -0400
              Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-29 16:39 -0400
          Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-29 05:07 -0700
            Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:41 -0400
  Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 07:49 -0400
    Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 16:07 -0400

csiph-web