Mike London

Ranch Hand
+ Follow
since Jul 12, 2002
Cows and Likes
Cows
Total received
11
In last 30 days
0
Total given
0
Likes
Total received
33
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike London

Campbell Ritchie wrote:

Mike London wrote:. . . I didn't use the Enumeration to get Calendar.JANUARY.

Unfortunately, it isn't an enumeration (small e; an Enumeration with large E is something different), nor an enum, nor anything enumerated; it is simply ints as constants in the class. Had it been enumerated, as this is, you wouldn't have the problem of entering 2 and getting MARCH. You would have a compiler error from anything requiring that enum.



Thanks,

-- mike

On behalf of the other people who gave you more of an answer than I did:-

That's a pleasure



Thanks Campbell. Good to know. And, BTW, you've been very helpful.

- mike
4 weeks ago

Campbell Ritchie wrote:One reason for abandoning Calendar and Date is that the month numbers in Calendar are unintuitive.



Totally agree. I'm completely on the Java 8+ DateTime API now, but needed another test case today with this weird date math calculation from the third party application. As you can see above, to underscore your point, I made that "off-by-one" error that gave me the incorrect date since I didn't use the Enumeration to get Calendar.JANUARY.

Thanks,

-- mike
4 weeks ago

Carey Brown wrote:If you are interfacing Java to some 3rd party package (e.g. FileMaker), then presumably there is a way to get a date back out of the 3rd party program. A date could take several forms: a String, a Date (or related) object, or some number of seconds or milliseconds since some epoch. What does FileMaker's API offer you?



The problem was comparing dates Java created (Period.between(....)) with FileMaker's date calculations. FileMaker got 3/2/2000 for January 31, 2000 + 1 month where Java got the expected 2/29/2000.  It seems FileMaker makes different assumptions near leap year than every other product I tried (Java, JavaScript's "adjust" function, Excel, and a Web site I found that got the same results as the other three for date math).

FileMaker's date API is nearly non-existent. Just a few functions. Compared to Java, well, .... Fugetaboutit.

Thanks again Cary!

-- mike
4 weeks ago

Carey Brown wrote:

Mike London wrote:Hello,

The two ways of getting a date one month in the future below do not give the same dates.

I'm confused then by what is a date one month in the future.

Example 1:


Prints 2000-02-29


-----------------------------------------------

But, ...

        Calendar zcal = Calendar.getInstance();
        zcal.set(Calendar.DAY_OF_MONTH, 31);
        zcal.set(Calendar.MONTH, 1);
        zcal.set(Calendar.YEAR, 2000);
        zcal.add(Calendar.MONTH, 0); // add a month

Prints: 2000-03-02

What?!

How can these values be different? Which is correct? If both are "OK", then how do you decide which to use?

Thanks in advance,

- mike

JANUARY=0. So month '1' is FEBRUARY. Plus '1' is MARCH. Hence 2000-03-02.

Should have written:



Thanks Cary,

That's very helpful.

Now the plusMonths(1) and Calendar match :2/29/2000!

A third-party program I'm using (FileMaker) seems to have a different algorithm.

This non-OO date function call below returns 3-2-2000 and seems to be the only option for adding dates there.

Date("01"+1 ; "31" ; "2000") = 3-2-2000

Based on now I have two other standard Date APIs that return 2/29/2000, which is what I expect, well, I don't know what to conclude about FileMaker's "data math".

By the way, in Excel, if you add 1 to January and you don't use the EDATE() function to add months (where you get 2/29/2000), you'll also get 3/2/2000.

Can be very confusing!

--

Thanks very much.

- mike
4 weeks ago

Stephan van Hulst wrote:You have to ask yourself, what does it mean to add a month to a date?

Do you add a fixed amount of time? Do you just increment the month field by one? If the latter, what do you do if you end on an invalid date (such as 31st of february)?

There is no single correct interpretation. Both classes have their own interpretation of what it means to add a month. Those interpretations may or may not be what you want, but you first have to explain what it is you're trying to achieve.



It's odd that I have to parse what it means to add a month, at first thought, unambiguous, but I suppose this is an edge case where that addition is open to interpretation.

Thanks,
4 weeks ago
Hello,

The two ways of getting a date one month in the future below do not give the same dates.

I'm confused then by what is a date one month in the future.

Example 1:


Prints 2000-02-29


-----------------------------------------------

But, ...

        Calendar zcal = Calendar.getInstance();
        zcal.set(Calendar.DAY_OF_MONTH, 31);
        zcal.set(Calendar.MONTH, 1);
        zcal.set(Calendar.YEAR, 2000);
        zcal.add(Calendar.MONTH, 0); // add a month

Prints: 2000-03-02

What?!

How can these values be different? Which is correct? If both are "OK", then how do you decide which to use?

Thanks in advance,

- mike
4 weeks ago
Hello,

I wrote the code below (Java 9+) to get a listing of dates between two dates that are either MONDAY, TUESDAY, or WEDNESDAY:



The question I have is whether there's a simple way (I didn't see it) to filter this list to only show bi-weekly dates.

So, instead of MONDAY, TUESDAY, and WEDNESDAY for each week, you'd skip three days after each MONDAY, TUESDAY, and WEDNESDAY.

---

The way I ended up doing this was to process the resulting List in a loop and print three days, skip three days, print three days, ....

Just wondering if there's a better way.

Thanks!

- mike
1 month ago

sonai kale wrote:I use ubuntu 16.04 and because I already had openJDK installed, this command have solved the problem. sudo apt-get install openjfx  Don't forget that JavaFX is part of OpenJDK.



Hi,

As I noted my my latest reply above, the issue was fixed.

Thanks,

- mike
1 month ago

Campbell Ritchie wrote:Your code compiled and ran without changes at my terminal:-The warning is about you using Data as a raw type. JavaFX has been included with the standard JDK download since (I think) Java8, four years ago. Please check whether there is an error with your IntelliJ settings. I shall add this discussion to the IntelliJ forum



Yes, I create a new project and it worked fine.

This was my goof.

In Intellij, under language levels, I didn't have the correct "language level".

It's fixed now.

FWIW, the problem happened as I was trying to find a library that was causing Intelilj (Java 10) to run out of Heap Space during running so I was doing lots of fiddling around.

Thanks very much for the replies!

- mike

Thanks,
2 months ago
To fix this issue, I had to manually add the JavaFX JAR file from Java 8 to the project.

/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/ext/jfxrt.jar

It's strange, but there isn't even a "jre" folder in the JDK 10 install (see attachment).

Similarly, doing a "locate" shows no jfxrt.jar in the JDK 10 install elsewhere.

Don't get what happened.

Thanks,

-- mike
2 months ago

Norm Radder wrote:

when I try to run it in Java 10


What do you mean by "run"? 
Are the errors from compiling
or from executing the compiled code?

I get symbol not found 


Can you copy the full text of the error messages and paste it here?



I guess I should have said that the program "appears" to compile. That is, in Intellij, there are no errors in the editor. I can click an object and the "." and see available methods.

Yet, if I do try to re-compile the code, I get errors including these:

Error3, 26) java: package javafx.application does not exist
Error4, 20) java: package javafx.scene does not exist
Error5, 26) java: package javafx.scene.chart does not exist
Error6, 26) java: package javafx.scene.chart does not exist
Error7, 26) java: package javafx.scene.chart does not exist
Error8, 26) java: package javafx.scene.chart does not exist
Error9, 20) java: package javafx.stage does not exist
Error18, 38) java: cannot find symbol
  symbol: class Application
.
.
.

The confusing thing is that, as I noted above (see attachment), the method drop-downs are working so I'm baffled why the code won't compile.

Thanks in advance,

- mike
2 months ago
The code below compiles. I get method drop downs, etc., but when I try to run it in Java 10, I get symbol not found for all the JavaFX classes (Application, scene, etc.).

Supposedly, it won't be until JDK 11 this September (2018) when Oracle removes JavaFX from the standard JDK.

What do I need to do to get this simple code to run as in Java 8?

The example below is a simple example. I also downloaded an example from the Oracle site with the same errors.

Thanks,

- mike


2 months ago

Hans Wursti wrote:I have exactly the same problem since last night. Seems to be on their side.



Thanks Hans.

I just bought a Java 9 book only to find that after only about a year, it's already .... obsolete! ;)

IAC, doesn't seem like there's that much new in Java 10 so I hope the book is still up to date on the Java 9 features and none of those changed.

-- mike
2 months ago
At this URL http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

After accepting the license agreement and clicking to download, I get (tried with all operating systems):


We're sorry, the page you requested was not found.
We have recorded this error (404) to help us fix the problem.
You may wish to try again using one of the tools below.
* Back to Previous Page ^ Site Map
* Product Index
* Software Download Index
* To search for your page, try our Search function.
search site Technology Network Q Q. Refine Search

===

This problem may be fixed by the time anyone reads this, but I'm just wondering if anyone has seen this error (or sees it now).

7:28 AM Mar 24, 2018

Thanks,

- mike

2 months ago

Campbell Ritchie wrote:In this thread, Liutauras drew our attention to the new version of Java┬«; he also proivded this link which says what the differences are. Have a look at that article and see how big the differences are. I suspect there will be relatively few Java10 books because its lifetime will only be six months.



Thanks to the suggestions.

I've been doing Java for 16 years and still learn something new almost every day.

I'll order the Java 9 book.

- mike
2 months ago