jodatime

Jadira usertype no class def found

不问归期 提交于 2019-12-11 10:12:15
问题 I'm trying to persist a JODA LocalDate attribute using Hibernate. @Column(nullable = false) @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") private DateTime scheduledDepartureTime; I downloaded the following jars: usertype.jodatime-2.0.1.jar usertype.spi-3.0.0.GA.jar usertype.core-3.0.0.GA.jar and added them to my classpath. When trying to execute my application, I get java.lang.ClassNotFoundException: org.jadira.usertype.dateandtime.shared.spi

Type value plusHours is not a member of org.joda.time.DateTime

点点圈 提交于 2019-12-11 09:44:28
问题 I'm using Scala and Joda time, but I can't use most methods. For example this works fine var now = DateTime.now() But this doesn't var now = DateTime.now() var then = now.plusHours(2) Type value plusHours is not a member of org.joda.time.DateTime If i build i receive also these errors: error while loading DateTime, Missing dependency 'class org.joda.convert.FromString', required by C:\Documents and Settings\Vallo\Mis documentos\Downloads\joda-time-2.2.jar(org/joda/time/DateTime.class) TP4

Joda DateTime DateTimeZone

别等时光非礼了梦想. 提交于 2019-12-11 08:51:57
问题 +I have a time tracking app that uses joda DateTime to persist Start/End time with ORM-lite. ORM-lite stores a Joda DateTime as long in database by using its millis. Joda DateTime.getMillis() returns Milliseconds in UTC. In a few days we switch from daylight-saving time to normal time and I'm not 100% sure if my app will handle this correctly. To test it I tried to disable the "Automatic date & time (Use network-provided time)" setting of my device and changed the date to one that has normal

how to get weekends in an Interval? joda time

混江龙づ霸主 提交于 2019-12-11 08:21:36
问题 Interval interval = new Interval(new DateTime("2014-01-01"), new DateTime("2014-01-30")); Is there a way to get the weekend days numbers? something like: interval.toPeriod.getWeekendDays(); 回答1: Custom Iterator WeekendDayIterator is an Iterator of the weekend days in the Interval specified: class WeekendDayIterator(interval: Interval) extends Iterator[LocalDate] { var day = interval.getStart.toLocalDate private def peek = day.plusDays(1) def hasNext: Boolean = peek.isBefore(interval.getEnd

Does a library exist with Joda Time / iBATIS integration classes?

我怕爱的太早我们不能终老 提交于 2019-12-11 08:11:53
问题 It looks like I have to implement com.ibatis.sqlmap.client.extensions.TypeHandlerCallback for both DateTime and LocalDateTime Joda types. This isn't a big deal, but if it's implemented somewhere else I'd rather just use that. 回答1: There are no clean and flexible solutions, IMO. Jodatime dates are more flexible than the JDBC native types ( java.sql.Date , java.sql.Timestamp ...) and if you map to them you might be losing information (timezones). An "full" implementation, (perhaps bypassing the

Generic bounds with pre-generics raw types

大兔子大兔子 提交于 2019-12-11 08:04:15
问题 I've got a Collection with the element type of <K extends Comparable<K>> because it's ordered. I'm trying to use Joda LocalTime with this collection - e.g. MyCollection<LocalTime> . Unfortunately, apparently Joda is pre-generics; LocalTime implements raw Comparable . I'm getting the compiler error Bound mismatch: The type LocalTime is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Interval<K> I would expect this to work with just a warning, as it's

Java ResultSet.getTimestamp using Calendar & Thread safety

我怕爱的太早我们不能终老 提交于 2019-12-11 07:56:16
问题 My Requirements: Get a Timestamp (which is stored in UTC) from a database ResultSet and do it in a thread-safe way. My code currently looks like this: Calendar utcCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); while(rs.next()) rs.getTimestamp("utctime",utcCal); ...which works as expected; However seems quite costly to create a new Calendar object for each query (they are very frequent). I've been looking at Joda-time as a possible replacement, but can't quite figure out how to

Joda Time getSecondOfDay on DST switch day

拥有回忆 提交于 2019-12-11 07:34:26
问题 I'm getting strange behavior from Joda Time when trying to get the seconds since midnight on a DST switch day. My code: public static void main(String[] args) { DateTimeZone timeZone = DateTimeZone.getDefault(); System.out.println(timeZone); DateTimeFormatter dateFormatter = DateTimeFormat.shortDate(); DateTimeFormatter dateTimeFormatter = DateTimeFormat.fullDateTime(); LocalDate date = new LocalDate(2016, 10, 29); for (int i=0; i<3; i++) { System.out.println(); System.out.println

Parsing date in polish locale in Joda?

坚强是说给别人听的谎言 提交于 2019-12-11 06:16:38
问题 I have following date: eg. String rawDate = "pon, 17 lis 2014, 15:51:12"; and I would like to parse it. I call: DateTime time = new DateTimeFormatterBuilder() .append(DateTimeFormat.forPattern("EEE, dd MMM yyyy, HH:mm:ss") .getParser()) .toFormatter().withLocale(new Locale("pl")).parseDateTime(rawDate); But I get: java.lang.IllegalArgumentException: Invalid format: "pon, 17 lis 2014, 15:51:12" 回答1: Good question! The JDK uses its own text resources. So following Java-8-code produces an

Shift date an hour when in dst

爱⌒轻易说出口 提交于 2019-12-11 05:38:22
问题 I am processing a file line by line. Each line has a date in the following format: YYMMDD HHMM The file is basically recording a reading every 15 minutes. The recording is using day light savings for the time zone it is in. The issue I am having is during spring ahead and fall back. The recording is duplicating dates when fall back occurs and a gap when fall back occurs. Fallback example: 141102 0100 141102 0115 141102 0130 141102 0145 141102 0200 141102 0115 - duplicate 141102 0130 -