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


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

Re: Evaluation strings question?

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Evaluation strings question?
Date 2019-08-07 15:10 -0400
Organization A noiseless patient Spider
Message-ID <qif7ns$ll7$1@dont-email.me> (permalink)
References <868b9ba4-bc72-4ad4-8a13-a91bd1ae9c2e@googlegroups.com>

Show all headers | View raw


On 8/7/2019 2:47 PM, cdalten@gmail.com wrote:
> Given a method like the following...
> 
>   @TargetApi(24)
>      public void convertEndCivilianTimeToMilitaryTime(String endHour, String endMinute, String endAmOrPm) {
> [... see up-thread ...]
> 
> This part..
> 
> if (endAmOrPm.equals("PM") && !endHour.equals("12")) {
> 
> }
> 
> evaluates TRUE when I run the program program but evaluates FALSE when I test it on my IDE evaluate code screen. Can someone point me in the right direction as to why the strings display this kind of behavior? Because I have no clue why it does what it does.

     I have no clue, either, but it would be extremely useful to know
exactly what the input strings look like.  Print them with start and
end markers of some kind, so you can detect extraneous white space
and the like:

	System.out.println("endHour = [" + endHour + "]");
	System.out.println("endMinute = [" + endMinute + "]");
	System.out.println("endAmOrPm = [" + endAmOrPm + "]");
	// ... or use your favorite logging framework ...

     As a side observation, I sort of wonder whether the guts of this
method might do better to use java.text.SimpleDateFormat.  (I'm not
an Android developer, so maybe my ignorance is showing -- but if
SimpleDateFormat is available, it seems like it could be made to
do most of the work for you.)

-- 
esosman@comcast-dot-net.invalid
Five hundred thirty-two days to go.

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


Thread

Evaluation strings question? cdalten@gmail.com - 2019-08-07 11:47 -0700
  Re: Evaluation strings question? Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-08-07 15:10 -0400
    Re: Evaluation strings question? cdalten@gmail.com - 2019-08-07 12:28 -0700
      Re: Evaluation strings question? Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-08-07 15:32 -0400
      Re: Evaluation strings question? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-08-07 22:05 +0200
        Re: Evaluation strings question? cdalten@gmail.com - 2019-08-07 13:47 -0700
    Re: Evaluation strings question? Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 05:03 -0700

csiph-web