Skip to content
Advertisement

Tag: timestamp

Convert LocalDate to LocalDateTime or java.sql.Timestamp

I am using JodaTime 1.6.2. I have a LocalDate that I need to convert to either a (Joda) LocalDateTime, or a java.sqlTimestamp for ormapping. The reason for this is I have figured out how to convert between a LocalDateTime and a java.sql.Timestamp: So, if I can just convert between LocalDate and LocalDateTime, then I can make the continued conversion to

log4j vs. System.out.println – logger advantages?

I’m using log4j for the first time in a project. A fellow programmer told me that using System.out.println is considered a bad style and that log4j is something like standard for logging matters nowadays. We do lots of JUnit testing – System.out stuff turns out to be harder to test. Therefore I began utilizing log4j for a Console controller class,

Output RFC 3339 Timestamp in Java

I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in Java? Also, SimpleDateFormat cannot properly parse the example above. It throws a ParseException. Answer Starting in Java 7, there’s the X pattern

Advertisement