I know this will give me the day of the month as a number (11, 21, 23): But how do you format the day of the month to include an ordinal indicator, say 11th, 21st or 23rd? Answer The table from @kaliatech is nice, but since the same information is repeated, it opens the chance for a bug. Such a
Bounded, auto-discarding, non-blocking, concurrent collection
I’m looking for a collection that: is a Deque/List – i.e. supports inserting elements at “the top” (newest items go to the top) – deque.addFirst(..) / list.add(0, ..). It could be a Queue, but the iteration order should be reverse – i.e. the most recently added items should…
Hibernate @ManyToOne references an unknown entity
I am receiving the following Hibernate Exception: @OneToOne or @ManyToOne on Matchup.awayTeam references an unknown entity: Team The simplified Matchup class looks like this: The simplified Team class looks like this: Notes: Both Matchup and Team have subclasses. I’m not sure if this impacts the situati…
Disadvantage of object composition over class inheritance
Most design patten books say we should “Favor object composition over class inheritance.” But can anyone give me an example that inheritance is better than object composition. Answer In Java, whenever you inherit from a class, your new class also automatically becomes a subtype of the original cla…
Android Socket + ObjectOutputStream not working correctly
I am developing a client/server program where the client is an android device. The server has a listener class that reads an object from the input stream. I created a client software for another COMPUTER that sends a small object over a local network. Computer to Computer works perfectly fine, i read the obje…
How project Lombok in java works and is that possible in .net using attributes?
Project Lombok makes it trivial to implement the boilerplate code in the classes. Is that possible with .NET attributes? Is any .net port there? Answer Well in Lombok a Java class might look like this While in C# the same class would look like this So C# (3.0 in this example) gets rather close without any oth…
commons beanutils alternative
I am looking for a commons beanutils alternative. The reason is that beanutils relies on commons-logging which is conflicting with existing libraries I am using. I would like a small self-contained alternative which will cause no/minimal conflicts. The main functionality I am after is nested property retrieva…
How to verify if a String in Java is a valid URL?
How to verify if a String in Java is a valid URL? Answer You can try to create a java.net.URL object out of it. If it is not a proper URL, a MalformedURLException will be thrown.
HowTo Unit Test Client Server Code
I’m currently writing a Java Client Server Application. So i want to implement two Libraries, one for the Client and one for the Server. The Client Server Communication has a very strict protocol, that I wan’t to test with JUnit. As build tool im using Maven and a Husdon Server for continues Integ…
nested Java collection to list items per person per day in a calendar grid using JSTL?
I am developing an employee scheduler Java web applicatyion where an employee can specify days they will be out of the office for things such as vacation, business travel, etc…I have a simple …