threetenbp

Parse Date String Return Wrong Month

我的未来我决定 提交于 2021-01-29 10:15:44
问题 I try to parse date string but always get wrong month. Here's my code. This is code to select date from calender @OnClick(R.id.tedit_tgllahir_addnew) void showTimeDialog(){ calendar = Calendar.getInstance(); year = calendar.get(Calendar.YEAR); month = calendar.get(Calendar.MONTH); date = calendar.get(Calendar.DAY_OF_MONTH); DatePickerDialog datePickerDialog = new DatePickerDialog(AddDataForNewUserActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet

Convert a timestamp before year 1900 in java

送分小仙女□ 提交于 2021-01-28 01:07:56
问题 My Android app communicate with an API which give me the following timestamp : -2209161600 . Converted to a date time, it's supposed to be 12-30-1899 00:00:00 The problem is, I tried to convert this timestamp using both the default library, threetenbp, and then jodatime, but I always get the same wrong result, using Europe/Paris timezone : 12-30-1899 00:09:21 Why does that happen ? EDIT: For example with jodatime DateTime dt = new DateTime(-2209161600000L, DateTimeZone.forID("Europe/Paris"));

How to convert LocalDateTime object into ISO string including time zone?

本秂侑毒 提交于 2020-06-12 02:49:22
问题 I am trying to convert a date/time string back and forth into a LocalDateTime object. I am using ThreeTenBp as the date/time library. String -> LocalDateTime val actual = LocalDateTime.parse("2016-12-27T08:15:05.674+01:00", DateTimeFormatter.ISO_DATE_TIME) val expected = LocalDateTime.of(2016, 12, 27, 8, 15, 5, 674000000) assertThat(actual).isEqualTo(expected) // Successful LocalDateTime -> String val dateTime = LocalDateTime.of(2016, 12, 27, 8, 15, 5, 674000000) val actual = dateTime.format

how to convert from ZonedDateTime to Joda DateTime

℡╲_俬逩灬. 提交于 2020-01-14 07:33:22
问题 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 because joda doesn't like the zone format Invalid format: "2015-01-25T23:35:07.684Z[Europe/London]" is malformed at "[Europe/London]" 回答1: ZonedDateTime zdt = ZonedDateTime.of( 2015, 1, 25, 23, 35, 7, 684000000, ZoneId

Weird org.threeten.bp.DateTimeException thrown?

杀马特。学长 韩版系。学妹 提交于 2019-12-31 00:57:08
问题 My code was working just fine. Today suddenly I started getting this exception - org.threeten.bp.DateTimeException: Field DayOfMonth cannot be printed as the value 1872095944 max width is 2 This is my simple code : LocalDateTime date = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd - MM - uuuu"); String sDate = date.format(formatter);//EXCEPTION THROWN HERE Why this problem suddenly? EDIT This seems to be an intermediate problem. It crashes sometimes and

threetenbp: Parse exception when parsing date with time-zone name

前提是你 提交于 2019-12-12 15:33:57
问题 I am trying to parse dates in the format of EEE, dd MMM yyyy HH:mm:ss zzz, so for example strings like "Tue, 16 May 2017 07:44:48 GMT" using threeten's DateTimeFormatter. However, it seems that the time-zone name can't get parsed for some reason (I tried to parse the same string just without the time-zone name part and that worked). Here is the parsing part of the code: DateTimeFormatter parseFormatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); ZonedDateTime

org.threeten.bp.format.DateTimeParseException: Text '2018-07-22T14:00:00-03:00' could not be parsed at index 19

拈花ヽ惹草 提交于 2019-12-08 09:18:20
问题 public static String formatter(String dateInPattern, String dateOutPattern) { OffsetDateTime dateInPatternFormat = OffsetDateTime.parse(dateInPattern, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ")); Date dateInValue = DateTimeUtils.toDate(Instant.parse(dateInPatternFormat.toString())); OffsetDateTime dateOutPatternFormat = OffsetDateTime.parse(dateOutPattern); return dateOutPatternFormat.format(DateTimeFormatter.ofPattern(dateInValue.toString())); } I need to enter a date in this

Comparing ThreeTen backport to JSR-310

我怕爱的太早我们不能终老 提交于 2019-12-04 20:46:29
问题 For some reasons, we can't use java 8 right now - we're still stuck at java 7. However, I'd like to use the new JSR-310 date/time APIs right now, using the official backport ThreeTen. Its homepage states: The backport is NOT an implementation of JSR-310, as that would require jumping through lots of unnecessary hoops. Instead, this is a simple backport intended to allow users to quickly use the JSR-310 API on Java SE 6 and 7. Questions: What are your experience with ThreeTen? Are there some

Motorola devices : org.threeten.bp.DateTimeException when parsing a date in ThreeTen

为君一笑 提交于 2019-12-04 14:55:26
问题 I have a very weird behaviour on some Motorola devices where LocalDateTime.now() is returning 0000-00-00T00:00:00.0 with ThreeTenABP. The code is as follow: @Override protected void onResume() { super.onResume(); if (!TextUtils.isEmpty(timeout)) { LocalDateTime savedTime = LocalDateTime.parse(timeout, DateTimeFormatter.ISO_DATE_TIME); if (LocalDateTime.now().isAfter(savedTime)) { refresh() } } } @Override protected void onPause() { super.onPause(); LocalDateTime currentTime = LocalDateTime

Motorola devices : org.threeten.bp.DateTimeException when parsing a date in ThreeTen

为君一笑 提交于 2019-12-03 09:17:31
I have a very weird behaviour on some Motorola devices where LocalDateTime.now() is returning 0000-00-00T00:00:00.0 with ThreeTenABP . The code is as follow: @Override protected void onResume() { super.onResume(); if (!TextUtils.isEmpty(timeout)) { LocalDateTime savedTime = LocalDateTime.parse(timeout, DateTimeFormatter.ISO_DATE_TIME); if (LocalDateTime.now().isAfter(savedTime)) { refresh() } } } @Override protected void onPause() { super.onPause(); LocalDateTime currentTime = LocalDateTime.now().plus(Duration.ofMinutes(10)); timeout = currentTime.format(DateTimeFormatter.ISO_DATE_TIME); }