Mike London

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

Recent posts by Mike London

Ivan Jozsef Balazs wrote:

Mike London wrote:

You have the string stringToConvert, encode it into a sequence of bytes using the UTF-8 encoding, then create a string from this sequence assuming it is a sequence of bytes using the platform's default charset. Don't we smell some fish around here?

Don't think there's any fish. This code, as I said, works perfectly standalone.

Yet, when I pass in a URLEncoded String which I correctly decode to the string I want to get the UTF-8 from, I just get that UTF-16 string back, not the UTF-8 version.

Please take a look at the attachment for more clarity.

Suggestions would be appreciated.


-- mike
5 days ago

Wade Zhang wrote:If you mean force to two repo be the same version, you can add "-f" to push

Wow, a response four years later! Thanks, man.

I still have Tower, but I now just use Git via the IDE. So much easier and only one program to worry about.

Thanks again for your posting.

- mike
I have the code below that works fine standalone, that is it converts \u003c to a less-than character.

But, when I pass the URL Encoded representation of that to a web service, even though stepping through it, I see the value it's trying to convert (same code as standalone that works) is "\u003c", it doesn't work.

Instead, it just gives me "\u003c" back.

If I hard code the "\u003c" in the web service, then it works.

So, I'm baffled what's the difference.

Thanks for any suggestions.

5 days ago

Rob Spoor wrote:If you want to replace one character with another, why not use string.replace(delimiterChar, '|')? Or, to replace one string literal with another, use the other replace method. replaceAll is overkill if you don't have a regular expression.

Thanks, It's working now.

-- mike
5 days ago
Hi all,

I have some code where I'm trying to update a file's delimiters, say from "," to "^", or whatever.

The problem is that some characters don't "split" correctly or "replaceAll()" depending on the character.

What I need to be able to do, somehow, is prepend "\\" to the variable so that, for example, the replaceAll() works correctly.

Prepending "\\" to text works fine, but I don't see how to do it with a variable.

Java doesn't like the syntax: string.replaceAll("\\"+delimiterChar, "|"), for example.

Thanks in advance,

- mike
6 days ago

Campbell Ritchie wrote:Back in 1972 a company were given a bill with the due date of 30th June so they paid the first instalment on 30th June, the second on 31st July and the third on 31st August. Or something like that; 1972 was a long time ago. The creditor took them to court for late payment and lost; the court ruled that a bill due on the last day of the month remained due on the last day of the month. The creditors should have known better.
I think that one month after 31st January 2000 was 29th February 2000. Your 2nd March date is actually 31 days later, but that is incorrect, at least I think it is. You are adding January not February. But, yes, this is a corner case and people will disagree with each other. Go and find the old Calendar and Date classes; don't use them, but they had lenient and non‑lenient modes. Details in the Calendar documentation.
Yes, it is a business decision you will have to make. And don't send me a bill due on 29th February; I shall be entitled to pay the second instalment on 31st March

Good info as always.

Thank you!

- mike
1 week ago
Using Java 8 and plusMonths(), we get one month from Jan 31, 2000 is 2000-02-29.

But, using JavaScript, we get 2000-03-02.

I've used other products and most, but not all, seem to agree with Java's 2000-02-29.


So, is "one month from Jan 31, 2000" a business case decision for a particular company or application?

There doesn't seem to be universal agreement with API functions.

This is confusing since people argue (on both sides) which date is correct for this edge case.


- mike
1 week ago

Tim Moores wrote:Like this: https://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html. The regular JRE updates will of course ship with the latest data out of the box.

Also see https://www.oracle.com/technetwork/java/javase/tzdata-versions-138805.html for which JRE version has what timezone data. That page also points to an RSS feed if you want to stay on top of these updates.


That's awesome!  Exactly what I needed to know.

Thanks very much.

- mike
3 weeks ago
Hi all,

Now that Morocco has abruptly dropped the time change, as you can read, here: https://www.bbc.com/news/world-africa-45995634

How does the Java Date/Time API get updated so API calls for future times (or for current times in the future) will be correct for that TimeZone?


- mike
3 weeks ago

Tim Holloway wrote:That's about it.

I recommend you get a copy of Portecle, an open-source java-based GUI tool for keystore manipulation and certificate management. It can make the processes a lot easier.

Note also that a keystore file is self-contained. That means that you can create test keystores and muck around with them outside your production environment, then copy them to production servers when you have what you want.

Thanks Tim,

You're the best!

I've used Portecle previously, but end up back at the command line sooner or later..

I also tried Keystore Exporer, but it doesn't seem to have any facility to import private keys.

Appreciate the great help and support on this amazing forum.

- mike
1 month ago

Ron McLeod wrote:You will need both the private key and the cert issued by the CA (and possibly an intermediate certificate depending on the CA).

Do you have the private key?  If it didn't already exist, it would have been created when the CSR was generated.

Since keytool wasn't initially used to generate the site's certificate, I'm assuming I would need to:

1. Import the PEM file (private key) into a new keystore. (CSR probably doesn't matter?)

2. Import the certificate files as would be the normal course of action creating keystore.


- mike
1 month ago

Tim Holloway wrote:A CSR is a Certificate Signing Request. It's what you send to your registrar for them to sign and return as the actual cert. A keystore stores private keys and certs, not - unless I've forgotten something - CSRs, which as far as I can recall are useless once they've been signed.

However, a cert doesn't carry a port number on it. So you should be able to use the same cert for both ports, assuming that the domain name on the cert matches the domain name for the Tomcat Host.

These days I'm not a big fan of using SSL on Tomcat anyway. Instead I front Tomcat with a reverse proxy like Apache or Nginx and use SSL on the proxy. Note, however, that the Tomcat cert files are in a different format than those used by Apache/Nginx (there is a nice GUI utility that can translate them, though).

Aside from that, even if you want Tomcat to be encrypted, port 8080 is supposed to be the unencrypted port. The standard for its SSL port is 8443.

Thanks Tim.

Since I don't really have control over the server, the SSL certificate is probably the best I can hope for.

Not exactly sure how to do this import given that the private key doesn't get generated in the keystore since it didn't generate the CSR, but I'm sure I can import it.

I'll contact the CA for more info.

Thanks again,

- mike
1 month ago

I have a client who already has an SSL certificate for their site. Tomcat is running on the same FQDN, but on port 8080.

Thus, rather than paying for a new certificate, the client wants to know if we can use the same certificate to secure Tomcat.

Since I've always used keystore to generate the CSR, first, and go from there, is it possible to somehow use the CSR they used to get the original certificate into keystore?

IOW, how would I, if it's possible, create a keystore suitable for Tomcat, given an already-created and issued certificate?

If this importing a CSR, or whatever, is a bad idea, just let me know too.

Thanks in advance,

- mike
1 month ago

Liutauras Vilda wrote:g tsuji, have a cow.

Certainly more elegant way to do that in this particular case.

Man, that's amazing!  I wasn't even aware you could chain methods like that off the SAXBUilder().

JDOM is an odd beast in that it's such a sweet API on the one hand, but, on the other hand, it's nearly impossible to find through documentation with plentiful examples.

Regardless, seems like how ever much I "think" I know, there's still so much more to learn (since starting Java in 2002). The Java 8 syntax still eludes me sometimes. I like its declarativeness, but often, what I want to do is complicated and raises the question whether it's the best way to go vs. the formerly-traditional coding methods. In my case, I make small (meant to be searched) example programs for future reference.

Thanks again..Oh, I did find that capitalization problem and fixed it.


The actual problem was that the XML file had one or more incorrectly formatted dates that would not import into the third-party application. So, in the end, rather than using JDOM at all, I just read the XML file line by line and searched for the incorrect formatted date. Then if found, fixed it, and wrote the fixed date and the rest of the XML file to a new file.

You guys are amazing!


- mike

Liutauras Vilda wrote:

Mike London wrote:Didn't find anything.

For me it did and it still does.

My bad. Sorry. I had changed DATA to DATE. Yep, it works.

Very nice, thanks very much.

- mike