FAQ Database Discussion Community


Get difference between DateTime instances with clj-time

clojure,jodatime,clj-time
I am trying to calculate the difference between two DateTime instances using clj-time. I looked through the documentation and found clj-time.core/minus and clj-time.core/minus- but both require an instance of org.joda.time.ReadablePeriod and not one of DateTime. I would prefer to use cli-time, but if no solution exists, what would be the...

How to parse dHHmm to Duration?

java,jodatime
I have a string in format dHHmm that stands for a duration of time, and want to get the equivalent minutes. Therefore I'm trying to convert it into a org.joda.time.Duration.getMinutes() object. But there seems to be no kind of DurationParser that could be used for this. How could I best...

how to debug the matching of the date?

jodatime,logstash
I am matching events such as [Sun Jan 11 10:43:35 2015][3205.51466981] user idp : testing 10.234.22.220 (10.234.22.220) [61673782] with %{SYSLOG5424SD:timestamp}%{GREEDYDATA}user %{WORD:user} : testing %{HOST:ip} It works, I see the various fields in elasticsearch/kibana. Specifically timestamp in the example above is matched with [Sun Jan 11 10:43:35 2015] I now would...

Why this date is not showing in GMT?

java,jodatime,simpledateformat
I can see that GMT time is having 'Z' constant as an indicator that it is GMT time. However when I parse the GMT string, it still is printing local time. Code: SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); String timeGMT = "2015-05-21T08:42:27.334Z"; try { System.out.println("Time GMT>>>>>>"+outFormat.parse(timeGMT)); } catch (ParseException e) {...

java- difference between 2 different times in 2 different days [duplicate]

java,jodatime
This question already has an answer here: difference in seconds between two dates using joda time? 1 answer I want to write a program which shows the time remained from right now to a specific time in a date in future. as I want to use Joda-TimeI searched alot...

Using Joda DateTime with Hibernate in H2 Database - SQLError

java,hibernate,jpa,jodatime,h2
I'm using JPA - Hibernate 2.1 with Joda DateTime. For DateTime conversion I'm using org.jadira.usertype to work with Hibernate. This works all fine for development and local testing with H2 in-memory DB. But on our Jenkins server the tests always fail with some strange SQLExceptions. WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error:...

Update Joda-Time in Grails

grails,jodatime,localtime
I use Joda-Time via joda-time plugin in Grails to input time data, but its constructor shows time, which is one hour ahead then in my time zone. Compulsory timezone setting in constructor as like: new LocalTime(DateTimeZone.forID("Europe/Moscow")) doesn't help. I've heard, what it happens, because I've outdated timezone data containing old...

How to convert from org.joda.time.DateTime to java.time.ZonedDateTime

java,datetime,timezone,jodatime,java-time
I have a data source with joda time DateTime objects stored. I need to convert them into java ZonedDateTime objects, keeping the original timezone. It is not sufficient to keep the offset since some DateTime objects represents daily repetitive tasks, and these tasks must occur at a specific time in...

Python - Calendar Experts - Whether My Algorithm And Logics Correct Or Not?

python,calendar,jodatime
I did some research and wrote a program in Python to show Hijri(Islamic calendar) Date in this format... weekday_name, date, month, year I want to use this within one of my Apps. Just wanted to know whether my codes are correct or not. I am no way near of a...

Save LocaTime via SpringData to MongoDB

mongodb,spring-data,jodatime
I try to save a LocalTime (joda) field to the MongoDB with SpringData using spring-boot-starter-parent (org.springframework.boot 1.2.3.RELEASE) and get a StackOverflowError. The StackOverflowError is in BeanWrapper in the method public <S> S getProperty(PersistentProperty<?> property, Class<? extends S> type) Stacktrace: [email protected] daemon, prio=5, in group 'main', status: 'RUNNING' at org.springframework.data.mapping.model.BeanWrapper.getProperty(BeanWrapper.java:120) at...

Joda time - Not able to calculate months / years from Period in minutes

java,jodatime,periodformatter
Am using joda-time-2.5 in Android Studio project. I am not able to work out what I missing to be able to correctly format a String with years and/or months. The Period calculates correctly - but will not go beyond "Weeks" eg. 1000000 minutes is correctly formatted to "99wks, 1day, 10hrs...

Grails, Joda-Time plugin, TimePicker nullable not working

grails,jodatime,gsp
I have a domain class with the attributes start + end, both of them are LocalTime (Joda-Time plugin). I want the end Time to be nullable. For this purpose I used the following constraint: end nullable: true. Scaffolding is realized through the Joda template and it's working pretty good. The...

How to parse a date with 24h time using joda?

java,datetime,jodatime
How can I tell joda-time to automatically detect 24h Hour strings and parse them accordingly? DateTimeFormat.forPattern("YYYYMMDDhhmm").parseDateTime("201410171500"); Results in: org.joda.time.IllegalFieldValueException: Cannot parse "201410171500": Value 50 for clockhourOfHalfday must be in the range [1,12] at org.joda.time.field.FieldUtils.verifyValueBounds(FieldUtils.java:234) at org.joda.time.field.ZeroIsMaxDateTimeField.set(ZeroIsMaxDateTimeField.java:86) at...

Java 8 LocalDate- determining the year of a yearless Feb-29 date?

java,date,java-8,jodatime
My colleague and I have an interesting problem. We work with an old system that only returns date data in the format ddMMM. If the day/month is in the past for the current year, then we are to assume this date applies to next year. Otherwise it applies to the...

What is the most accurate joda-time representation for “DateUTC”?

java,date,datetime,jodatime,utc
Up until now we have been using joda-time class DateTime to represent date-time data with UTC timezone, and this meets our requirements nicely. Example: 2014-11-07T14:10:00Z Now, we have a requirement to represent "date" data (in UTC timezone). Example: 2014-11-07 There exists a LocalDate joda-time class, and a method to convert...

How to convert Days in Year(s), Month(s), and Day(s) with Jodatime?

java,jodatime
How to convert Days in Year(s), Month(s), and Day(s) with Jodatime? For example: days = 365; should print = 1 Year(s), 0 Month(s), and 0 Day(s) Days days = Days.days(365); Period p1 = new Period(days); PeriodFormatter dhm = new PeriodFormatterBuilder() .appendDays().appendSuffix(" days", " Dias").appendSeparator(", ") .appendMonths().appendSuffix(" months", " Meses").appendSeparator(", e...

How to print a localized date with only month and day (no year) in Java? [closed]

java,jodatime
I'd like to print a date in Java containing only the month and the day (no year). It's gotta be localized, so that it prints "May 2015" is the US, and "2015년 5월" in Korea (notice that in US the years comes after the month, but in Korea it comes...

Use an implicit TypeHandler based on resultType for select in MyBatis

java,jodatime,mybatis
I am trying to select a timestamp in MyBatis and return it as a LocalDateTime (from joda-time). My configuration works fine if I try to return the result as a java.sql.Timestamp. I proved my type handler works fine: if I use a wrapping class with a LocalDateTime as only field...

Conversion between Time Zone gives incorrect results

java,datetime,time,jodatime
DateTime dt = new LocalDateTime(rs.getTimestamp("LastUpdated").getTime()).toDateTime(DateTimeZone.forID("America/New_York")); Timestamp t=new Timestamp(dt.getMillis()); The result I get from this doesn't match the actual Time of the "America/New_York". It is off by several hours. What could possibly be the problem? Update- This is the Time I want to convert which is from the DB: 2015-04-28...

how to import joda time in java on Ubuntu system

java,date,ubuntu,import,jodatime
I'd like to generate dates sequence in a range. This thread suggests to use Joda-Time package. I downloaded it and unzipped it to the same directory as my Main.java. When I try import ./joda-time-2.7/org.joda.time.DateTime;, the compiler says: Main.java:4: error: expected import ./joda-time-2.7/org.joda.time.DateTime; ^ Main.java:4: error: expected import ./joda-time-2.7/org.joda.time.DateTime; ^ Main.java:4:...

How to get the time difference in seconds? [duplicate]

java,datetime,jodatime
This question already has an answer here: Java-How to calculate accurate time difference while using Joda Time Jar 2 answers I have used Jodha Library and tried to get the difference between two dates in seconds. But it is only accurate up to the date. Not to the seconds....

Does Objectify support Joda-Time Interval class?

java,google-app-engine,jodatime,objectify,google-cloud-datastore
We use Objectify 5 to access Google Cloud Datastore. We have an entity with a property of type Interval from Joda-Time library. When we try to save such an entity, we get the error below. It seems that Objectify has problem with Chronology and its subclasses. com.googlecode.objectify.SaveException: Error saving MyEntity(null):...

How to use properly DateTimeFormatter / convert from java.time.Instant [duplicate]

java-8,jodatime,jsp-tags,java-time,jsr310
This question already has an answer here: How to covert Joda-Time's DateTimeFormat.forStyle() to JSR 310 JavaTime? 2 answers Ok, I need some help to understand how to use the java.time formatters. I keep crashing on "Unsupported field" exceptions all day (pun not intended, sorry). Just some examples. This is...

How to get difference between 2 dates in number of days,hours,minutes and seconds

java,jodatime
I want to get the number of days,hours and minutes between 2 given dates and so far I have tried in 3 different ways but none gives me the correct value.Please let me know how to get number of days,hours and minutes in between 2 given dates. In all the...

How do I get the date of 31 days ago?

java,jodatime
How can I get x which should be 31 days before current_date? x(date)___________________________current_date 31 ...

Spring Portlet Jquery Ajax post json dateTime conversion error

jquery,json,spring,jodatime,spring-portlet-mvc
This question is related to: Spring Portlet Jquery Ajax post to Controller I'm submitting a form from Jquery Ajax to Spring Portlet MVC Controller. The issue is startTimestamp and endTimestamp are dateTime in the POJO. The json sends it as a string and the conversion is not happeinng. The error...

java.time.Instant -> java.sql.Timestamp behaving differently on Windows vs *nix (timezone-related)

java,hibernate,timestamp,jodatime,java-time
Somewhere in the code I have Timestamp ts = Timestamp.from(instant); where instant is, as the name suggests, java.time.Instant. (Why? To allow Hibernate 4.x to persist, via a UserType, JDK8 time types, not yet supported before Hibernate 5). In fact, let me put the code so it's clear. The log statement...

Spring Boot ignores @JsonDeserialize and @JsonSerialize

java,spring-mvc,serialization,spring-boot,jodatime
I've a Spring Boot application with RESTful endpoints that I want to add custom serializers to for joda-time but I can't get the applications default Jackson serailzier to recognize my custom one's. I created RESTFul endpoints using @RepositoryRestResource @RepositoryRestResource(collectionResourceRel = "x", path = "x") public interface XRepository extends PagingAndSortingRepository<X, Long>...

Multidex duplicate entry with Joda Time

android,jodatime,multidex
I just enabled Multidex support for my app and now I am getting this error from my Joda time dependency. I am also using a library gson-jodatime-serialisers that depends on Joda. Not sure if it's causing the duplicate issue. Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: org/joda/time/base/AbstractDateTime.class apply...

How to add GMT from date string

java,jodatime
This is the date coming from db 2015-06-0403:34:38 I have parsed it like this DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm:ss"); DateTime dateTime = formatter.withOffsetParsed().parseDateTime("2015-06-0403:34:38"); result : 2015-06-04T03:34:38.000+05:00 Now I want this date to add the GMT automatically with +5 in this case so the date would be 2015-06-04 08:34:38 I have tried...

Is there a way to print a DateTime in milliseconds?

java,jodatime
I want the same result as this: dateTime.toDate().getTime() + "" NOTE: That + "" converts it to a String. Does JodaTime's date formatter have a way to do this? I want to do something like this: dateTime.toString(x); to get the same result. I tried this: new DateTime().toString("SSS") But this prints...

how to convert from ZonedDateTime to Joda DateTime

java,jodatime,threetenbp
I've switched to threeten for date times but I've still got a 3rd party tool that uses joda to write timestamp with timezone to the database and I need to convert from one to the other. What's the best way? As a workaround I tried DateTime.parse(zdt.toString) but it falls over...

Difference between MySQL datetime and joda time

java,mysql,jodatime
Mysql date time is like this: 2015-05-01 21:36:38.0 And joda current time: DateTime now = new DateTime().toDateTime(); outputs 2015-05-01T22:08:15.705+02:00 How to get the difference between these 2 dates 2015-05-01 21:36:38.0 and 2015-05-01T22:08:15.705+02:00 in minutes? ...

Serialization and Deserialization of JodaTime dates as json

java,json,jackson,jodatime,jackson-modules
According to the documentation found here https://github.com/FasterXML/jackson-datatype-joda the following code snippet should pass ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JodaModule()); final String INPUT_JSON = "{\"start\" : \"1972-12-28T12:00:01.000Z\"}"; Bean bean = mapper.readValue(INPUT_JSON, Bean.class); String json = mapper.writeValueAsString(bean); Assert.assertEquals(INPUT_JSON, json); However, this instead returns: org.junit.ComparisonFailure: Expected :{"start" : "1972-12-28T12:00:01.000Z"} Actual...

DateFormat from ''yyyy-MM-dd“ to ”dd-MM" using Joda-Time

java,date,datetime,jodatime
I have following code: DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MM"); LocalDate weekMon = new LocalDate().withWeekOfWeekyear(thisWeek).withDayOfWeek(DateTimeConstants.MONDAY); System.out.println(weekMon.toString()); LocalDate weekFin = dtf.parseLocalDate(weekMon.toString()); and the output prints the date correctly: 2015-02-02. I'm trying to convert it to European format and ignoring the year as "dd-MM" -> "02-02" but the line: LocalDate weekFin = dtf.parseLocalDate(weekMon.toString()); keeps...

Issue with DateTime after migration from jdk6 to jdk8

java,java-8,jodatime,jdk1.6
I found out this annoying exception after migration from jdk1.6 to jdk1.8. For 1.6 it works fine, but 1.8 returns null: import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.junit.Test; public class JodaTest { public static final String strDate = "Nov 2 2010 12:27AM"; private static final String ISSUED_DATE_PATTERN...

java.lang.IllegalArgumentException: Invalid format

java,jodatime
This code: DateTimeParser[] parsers = { DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss zzz").getParser(), DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss").getParser(), DateTimeFormat.forPattern("dd/MM/yyyy HH:mm").getParser(), DateTimeFormat.forPattern("HH:mm").getParser() }; DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); Session session; DateTime dTime = null; Calendar calendar; try{ if (completedTime != null && !completedTime.equalsIgnoreCase("")){ LocalDateTime jt =...

JodaTime Integer Min/Max Value parsing

java,jodatime
Can someone give me some information about this parsing behavior of JodaTime? String minValueString = new DateTime(Long.MIN_VALUE).toString(); System.out.println(minValueString); DateTime minDateTime = DateTime.parse(minValueString); System.out.println(minDateTime.toString()); prints this, -292275055-05-16T17:40:32.192+00:53:28 but throws this Exception for the parsing part org.joda.time.IllegalFieldValueException: Cannot parse "-292275055-05-16T17:40:32.192+00:53:28": Value -292275055 for year must be in the range [-292275054,292278993] ...

Parsing String Timestamp as JODA TimeStamp

timezone,timestamp,jodatime
Given the following UTC time: 2009-11-17 10:45:32 How can I create an org.jode.time.LocalDateTime with that exact time, but in UTC? In other words, that time-stamp represents a UTC time. I'd like to make a new Timestamp object in joda with that time in UTC. I tried the following unsuccessfully: scala>...

How to check if current date is between two reoccurring dates in java? [duplicate]

java,date,jodatime
This question already has an answer here: How can I determine if a date is between two dates in Java? 10 answers I am trying to create an app, and got stuck at calculating if today is in the school year. The user enters two dates, with no year,...

Is it somehow possible to extend Joda-Time classes marked final?

java,jodatime
I really like Joda-Time, but I've run into something I consider to be a problem. I'd like to extend some of the classes, specifically DateTime, LocalDate and LocalDateTime. But they are marked "final". I found a very old thread where this is explained as being a way to ensure the...

Can I make JodaTime DateTimeFormat lenient about the milliseconds of a date?

java,jodatime
I have this unit test that is failing and I would like to get it to pass: @Test public void testDateFormatsWithNo() throws Exception { List<String> dateStrings = Lists.newArrayList("2014-08-02T22:21:32Z", "2014-05-27T17:11:55.597Z"); try { String twoMillis = "yyyy-MM-dd'T'HH:mm:ss'Z'"; for (String dateString : dateStrings) { DateTimeFormat.forPattern(twoMillis).parseDateTime(dateString); } } catch (Exception e) { fail(e.getMessage()); }...

Convert Time-String using joda-time [duplicate]

java,jodatime
This question already has an answer here: Java : how to add 10 mins in my Time 6 answers I have to following time-string: "23.02.2015 14:06:30 +01:00" which I want to print. The printed result should be: "23.02.2015 15:06:30". After some research I just found a solution which I...

How to parse time without timezone conversation?

java,jodatime
I'm parsing a xs:datetime to joda DateTime, but would like to parse it without the timezone, and let the date+time remain unchanged. How could I achieve this? The following subtracts the timezone instead, but that's not what I want. ISODateTimeFormat.dateTimeParser().parseDateTime("2015-10-25T08:45:00.000+11:00"); //2015-10-24 23:45:00 WHY? ...

Get minutes between two working days in Java

java,datetime,jodatime
I am trying to calculate the minutes between two Joda DateTimes or Calendars in Java. Ofcourse this would be simple if I could use the Minutes.minutesBetween function, but I can only count the minutes between working days and 8:00 AM - 6:00 PM. E.g.: Startdate: 03-11-2015 16:00 Enddate: 03-11-2015 17:00...

Elasticsearch cannot parse date using custom format

parsing,date,elasticsearch,jodatime,datetime-format
According to the documentation (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html), it should be possible to parse dates using a Joda time compatible date pattern. My data contains dates like this: "2015-02-09 02:10:05,245". These can be parsed with Joda time using the following pattern: "yyyy-MM-dd HH:mm:ss,SSS". However, when I tell my index to use this pattern...

Usage of joda.time in icCube

jodatime,iccube
I would like to use the following MDX statement: with member [x] as now()->plusMonths(1)->withDayOfMonth(1)->minusDay(1) select [x] on 0 from sales But I get the error "withDayOfMonth" is unknown. I know the function "plustMonths()" works fine. How can I make this other Joda function work? The following line is active in...

How can i use org.joda.time.LocalDate and java.time.LocalDate at the same time; [duplicate]

java,javafx,jodatime
This question already has an answer here: Importing two classes with same name. How to handle? 7 answers I'm practicing on how to work with dates. But i got stuck when i want to use a javafx datepicker. since it only works with java.time.LocalDate i was trying something like...

Slick column mapper java.sql.Time to Joda LocalTime

scala,jodatime,slick
Looking to map java.sql.time to some joda time class. Having some issues with the mapper, it throws an error message. Has anyone performed this conversion? trait DateMapper { implicit val DateMapper = MappedColumnType .base[java.sql.Time, org.joda.time.LocalTime] ( d => new LocalTime(d.getTime)) } Error Unspecified value parameters: tcomap:(LocalTime) => Time ...

How to parse time zone string “Pacific Time (US & Canada)” on JVM?

java,timezone,jodatime,yammer
I'm writing an integration with Yammer and it returns a time zone string that looks like this: Pacific Time (US & Canada) How does one parse this into a TimeZone or DateTimeZone on the JVM? I've tried TimeZone.getTimeZone and DateTimeZone.forID but to no avail....

Joda DateTime Json date format issue

json,datetime,gson,jodatime,jsonobject
I would like the JSON output to be in a particular date format. My JSON output is: "data":[[{"id":1,"createTimestamp":{"iMillis":1431463708237,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}},"startTimestamp":{"iMillis":1420092000000,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}},"endTimestamp":{"iMillis":1451541600000,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}}}]] But I would like the timestamps to be in this format: 2015-05-12T20:48:28.237Z My code: JSONArray a = new JSONArray(); a.add(aList); JSONObject j = new...

JodaTime: plusMonths(1) two times differ from plusMonths(2)

java,date,time,jodatime
Sample test @Test public void should_be_equals(){ LocalDate now = new LocalDate(2015,01,29); assertThat(now.plusMonths(1).plusMonths(1)).isEqualTo(now.plusMonths(2)); } The strange result: org.junit.ComparisonFailure: Expected :2015-03-29 Actual :2015-03-28 Why this differs?...

Android/Joda time - Convert dateTime to my local DateTime

android,datetime,timezone,jodatime
I am trying to convert server date string to my local/device set local time but without success. I am using Joda time library. What i am trying to do: private static String FORMAT_DATE_SERVER = "YYYY-MM-dd'T'HH:mm:ssZ"; public static DateTime parseServerDateToLocal(String raw_date) { DateTime result = DateTime.parse(raw_date, DateTimeFormat.forPattern(FORMAT_DATE_SERVER)).withZone(DateTimeZone.getDefault()); return result; } Still...

Joda - Print DateTime ignoring TimeZones

java,android,jodatime
I got two timestamps: 2015-03-30T00:36:00.000+0100 2015-03-30T00:36:00.000+0200 Only the timezone differs. After parsing this timestamp with DateTimeFormatter and printing only the time (without date) using DateTimeFormat.shortTime(). The results are: 00:36 23:36 Since only the times matter in my case I would like to ignore those timezones when printing the time. How...

Using JodaTime in Spark's groupByKey and countByKey

jodatime,apache-spark
I have a very simple Spark program (using Flambo in Clojure, but should be easy to follow). These are all objects on the JVM. I'm testing on a local instance (although I would guess that Spark still serialises and deserialises). (let [dt (t/date-time 2014) input (f/parallelize sc [{:the-date dt :x...

Better format to write pojos with date in REST

java,rest,date,datetime,jodatime
I want to create an entity by the use of POST operation in REST, my first problem is that my class has an date parameter where I am using jodatime Datetime. Something like: public class User implements Serializable { ... private Date birthday; public void setBirthday(DateTime birthday) { this.birhday =...

Unable to resolve class LocalTime grails

grails,jodatime,gsp
I need realize a time input in my Grails application. I've downloaded joda-plugin for it. But when I want test it, writing a such string from doc example: <joda:timePicker name="myTime" value="${new LocalTime()}" precision="second" />, I get such error: Unable to resolve class LocalTime How to fix it?

How to get hour and minutes difference from two localtime joda

java,math,jodatime
I want to get the difference between two LocalTime values in hours and minutes? Suppose i want the time difference between 6pm and 11.59 am, ie, 5.59 (5 hours and 59minutes). LocalTime startTimeOnlyEST = new LocalTime(startTimeEST); LocalTime endTimeOnlyEST = new LocalTime(endTimeEST); float quotient = Minutes.minutesBetween(startTimeOnlyEST, endTimeOnlyEST).getMinutes() / 60; By using...

Joda Period not converting all minutes to hours “8h, 132m”

java,android,jodatime,period,minute
I am storing two DateTimes (Joda) in an object and then I get a Period from the object by new Period(dateTime1, dateTime2). I then want to add all the periods from different objects together. I am both adding all the periods together in a variable and summing up some periods...

Joda betweenDays (LocalDate,LocalDate) not applicable

java,datetime,jodatime,java-time
I am having trouble using Joda daysBetween function. It keeps telling me The method daysBetween(ReadableInstant, ReadableInstant) in the type Days is not applicable for the arguments (LocalDate, LocalDate) when I try to insert two localdate items. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.ENGLISH); LocalDate date = LocalDate.parse(reviewDate, formatter); Date dateNow...

How to convert a Duration to Period in Joda?

java,jodatime
Can someone explain why the following tests fails? @Test public void testDuration() { Duration duration = Duration.standardDays(1); assertTrue(duration.getStandardMinutes() == 1440); //OK assertTrue(duration.toPeriod().getMinutes() == 1440); //NOK. result = 0 assertTrue(new Period(duration.getMillis()).getMinutes() == 1400); //NOK. result = 0 } ...

convert millisecond to Joda Date Time or for zone 0000

android,jodatime
please tell me how to convert milliseconds to joda Date time?? formatter = DateTimeFormat.forPattern("dd/MM/yyyy'T'HH:mm:ss").withZone(DateTimeZone.forOffsetHoursMinutes(00, 00)); even tried String millisecond="14235453511" DateTime.parse(millisecond); ...

Send LocalTime object via parameters from gsp in Grails

grails,jodatime,gsp
I've input time field in my Grails application: <joda:timePicker name="startTimeReservation" value="${new LocalTime()}" precision="minute" /> I want to send its value to action in controller via parameters. This is a code from controller where I catch this value: oldCafeeInfo.startTimeLimit = params['startTimeReservation'] During parameters are send, I get a such error: Cannot...

Date and time without timestamp in Javascript

javascript,date,jodatime,momentjs,datejs
In Javascript I need to work with the concepts of date, time and "date and time " without referring to a particular point in time. This is exactly the same semantics that joda time's LocalDate and LocalTime provide in Java. I've been briefly looking at Date.js and moment.js, but both...

Understanding Month Change with DateTimeFormatter#parseLocalDateTime

jodatime
Given the following DateTimeFormatter: scala> val dateTimeFormatter: DateTimeFormatter = DateTimeFormat.forPattern("yyyy-mm-dd HH:mm:ss.SSS") dateTimeFormatter: org.joda.time.format.DateTimeFormatter = [email protected] Why does passing "2015-02-05 22:27:36.491" to the following function decrease the month by 1? scala> dateTimeFormatter.parseLocalDateTime("2015-02-05 22:27:36.491").toDateTime res5: org.joda.time.DateTime = 2015-01-05T22:27:36.491-05:00 ...

How can I convert date time from time zone A to time zone B in Joda time?

java,jodatime
Imagine I have some datetime value coming from one system, and a timezone information (source and target time zones) coming from another. I need to convert the datetime from source to target time zone. For example, let's say I get a datetime in the Moscow time zone. I need to...

migrate from Joda time library to Java time(Java 8)

java-8,jodatime
I am trying to migrate from Joda time library to Java time (Java 8). I am unable to find equivalent of ISODateTimeFormat.dateOptionalTimeParser() in java.time Joda ISO formatter has nice parsers: ISODateTimeFormat.dateTimeParser() : generic - selects parser based on string parsed. Similarly: ISODateTimeFormat.dateOptionalTimeParser(). I am finding it difficult to change Joda...

Generate different period of time using joda

java,loops,datetime,iterator,jodatime
I have a scenario to generate specific time between two dates. Let's say Mar 1st to Mar 31st as my input. I need to generate datetime with specific hours as below. Mar 1st 03:00 - Mar 1st 06:59 Mar 1st 07:00 - Mar 1st 14:59 Mar 1st 15:00 - Mar...

Finding difference of days from start and end using joda? [duplicate]

java,json,jodatime
This question already has an answer here: Number of days between two dates in Joda-Time 4 answers I want to find out from the startDate and endDate how many days is it. From my json response, I can get back these in String: String startDate = "Fri, 10 Jan...

Print from joda-time DateTimeFormatter with optional Parser

java,datetime,jodatime
In a project using joda-time 2.1, I have the following DateTimeFormatter: /** * Parser for the "fraction" part of a date-time value. */ private static final DateTimeParser FRACTION_PARSER = new DateTimeFormatterBuilder() .appendLiteral('.') .appendFractionOfSecond(3, 9) .toParser(); /** * A formatter for a "local" date/time without time zone offset * (in the...

LocalDate with Joda constructor says The constructor LocalDate(int, int, int) is not visible

java,jodatime
According to the documentation in Joda: public LocalDate(int year, int monthOfYear, int dayOfMonth, Chronology chronology) Should take the above which I did. I tried to set Chronology to null but I get the following error: The constructor LocalDate(int, int, int, null) is undefined However I am passing the correct values,...

Java EE: NoClassDefFoundError org.joda.time.DateTime with IntelliJ and Maven

java,maven,intellij-idea,jodatime
I am using IntelliJ 14 I want to add joda.time lib in my project. When I add this lib manually (copy the jar file into lib repository, and add reference in Project Structure) everything work good, I can use the library in a servlet and show the result in a...

Jodatime issues on Android 5.0

android,jodatime,android-5.0-lollipop
My app has been working for some time, but after the release of Android 5.0 it crashes on devices running this version. I'm using JodaTime 2.6 for date handling and it's this library that suddenly throws the following exception: java.lang.IllegalArgumentException: Invalid format: "6:06:00 AM" is malformed at "AM" Ive verified...

Unable to Convert Time to Datetime using JodaTime Android

java,android,jodatime
i have a Time text field where the user can enter 9:30 AM or 9:30 PM in the text field, once they click the button for the next activity, i need to store that time in a DateTime field, the problem i am running into is, i cannot use DateTime.parse("9:30...

How to check user entered date is greater than 32 days from current date in java

java,validation,date,condition,jodatime
I would like to validate the date input of the user based on a condition. The condition is new date entered by user should be greater than 32 days. How to do the same?. I have tried the following but it is not working. final Date getuserDate = validate.date(); logger.debug("UserDate...

Why in order to compare hijri with iso dates you need to wrap a DateTime in LocalDateTime? (Joda)

java,datetime,calendar,jodatime,gregorian-calendar
I am trying to convert an ISO (Gregorian) date into a hijri (Islamic) date and the compare the first to a hijri date. What I do and it does not work is: Chronology iso = ISOChronology.getInstanceUTC(); Chronology hijri = IslamicChronology.getInstanceUTC(); DateTime dtISO = new DateTime("2015-03-12T10:04:43", iso); System.out.println("dtISO: " + dtISO);...