Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
I have the following snippet of code and contractModel.getName() returns "King’s" (truncated for this example but serves the purpose)

String trustName = contractModel.getName();
trustName = trustName.replace("’", "'");

For some reason this doesn't replace ’ with '. In fact it seemingly does nothing. Any ideas?

Adbot
ADBOT LOVES YOU

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried

Blacknose posted:

I have the following snippet of code and contractModel.getName() returns "King’s" (truncated for this example but serves the purpose)

String trustName = contractModel.getName();
trustName = trustName.replace("’", "'");

For some reason this doesn't replace ’ with '. In fact it seemingly does nothing. Any ideas?

Found the solution. ’ is extended ASCII character 146 and microsoft standard extended ASCII ignores a bunch of characters (127-150something?), so it needs to be escaped to the full unicode \u2019. That's 4 hours I'm never getting back. On the plus side I learnt more than I'll ever need to know about character encoding.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Hibernate and Spring JDBC make life so much easier; it's hard to believe how much better they are.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
I need a good Spring MVC book. Any ideas?

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
You could just catch a generic Exception.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
You're absolutely right, in this case catching Throwable would be the correct thing to do.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
I have a loving retarded question. I have a double, lets aay the value is 160.0, and I need it to be formatted as 160.00 (yeah, the cardinal sin of using doubles for currency, don't blame me, it wasn't my idea).

I have tried Math.round, DecimalFormat etc and I'm pretty well out of ideas. There has to be a way of forcing it to 2dp and staying that way whilst also keeping it as a double but I can't for the life of me think what and it's now starting to really gently caress me of. Ideas?

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Already tried that and it returns a string, I need to end up with a double, same as when I started. I'm not actually 100% convinced it's possible.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Yeah I was really scraping the bottom of the barrel by asking. It has to remain as a double, which obviously is a binary representation of a value, whih is then passed to an external api (jxl I believe) which then sticks it in an excel file. I didn't know if there was a way to attach formatting data to a double without using a string. The client is almost certainly going to want a numeric value with formatting which as far as I can tell just isn't possible.

It's one of those situations where you're basically boned but I thought someone might know some miraculous way of doing it that defies the laws of coding.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried

Jabor posted:

If it's going into Excel, why isn't a string suitable?

As far as I'm aware Excel treats a cell containing the string "160.00" pretty much the same as one containing the number 160 when it comes to calculations?

The client wants a numeric field in the spreadsheet for the software that will then read the excel file. Not my choice unfortunately.



epswing posted:

I don't think you're getting it. To "attach formatting data to a double" is senseless. You can round the value, or floor/ceil it, but numbers don't have "formats".

Trust me I get it; I know they don't. That's why I said attach formatting to it as opposed ot 'format it'. I could probably have worded it better however.

I'm not about to start pulling JXL apart, the client is just going to have to live with either a text field in excel or no dp, their choice.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
I thought the JXL formatters only dealt with fonts, borders etc but turns out that hidden away is the ability to format numeric cells. To get 2 decimal places on a numeric value use:

code:
WritableCellFormat floatFormat = new WritableCellFormat(NumberFormats.FLOAT);
and you should be golden. If I knew more about JXL or excel its self that would probably have taken 2 minutes, not 2 hours, but never mind.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried

tripwire posted:

Use intellij :D

I upgraded to eclipse indigo this morning for an ATG project (gently caress ATG, hybris all the way) and it crashed 10 times before lunch so I had to roll back to helios.

I really, really wish I could afford intellij currently :smith:

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Spring and Hibernate is pretty much the standard I think.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Pretty much the same as that, I've only seen it when redeploying big Spring apps.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
I need a good Spring/Hibernate textbook that walks through Spring MVC project setup etc. I've used Spring a lot but never done a complete greenfield project setup which I think is a pretty gaping hole in my knowledge.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried

TRex EaterofCars posted:

I don't think you need a textbook to do this, it's really not that hard especially with annotations in 3.0+. I would just make a few simple hello world-ish projects to get used to all the initial boilerplate web.xml stuff and some of the gotchas with dispatcherservlet and you should be fine.

I guess you're right. I have used Spring quite a lot, it's mainly just setup and some of the newer features. I guess I'll make some kind of noddy little webapp and see how it goes. Now if I can just stop getting distracted by Scala...

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Something subclassed from InvalidStateException, I reckon.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Oops, been coding javascript for 5 months, I think my brains gone a bit funny.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried

pigdog posted:

IDEA is even smarter than Eclipse when it comes to autocompleting and programming aides :)
http://blog.codeborne.com/2012/03/why-idea-is-better-than-eclipse.html

I'm trying to give IDEA a go at the moment and while stuff like that is really nice in it I just can't seem to get it to 'feel' right, if that makes sense.

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
Yeah there's no good reason to code that from scratch.

Adbot
ADBOT LOVES YOU

Blacknose
Jul 28, 2006

Meet frustration face to face
A point of view creates more waves
So lose some sleep and say you tried
yes

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply