All Questions
26 questions
0
votes
2
answers
531
views
Setting time zone offset in java 8 time versus joda time
I work for an organization in two locations. One of them is Chile, where daylight savings time is extremely unpredictable and often varies from year-to-year. We have an application that is dependent ...
1
vote
2
answers
976
views
Java8 equivalent of JodaTime DateTimeFormat.shortDate()
What is the Java8 java.time equivalent of
org.joda.time.formatDateTimeFormat.shortDate()
I've tried below way, but it fails to parse values such as "20/5/2016" or "20/5/16".
DateTimeFormatter....
5
votes
4
answers
8k
views
TimeZone.getTimeZone("PST") vs TimeZone.getTimeZone("America/Los_Angeles")
I'm Using Java 8,
Earlier in our code, We were using sdf.setTimeZone(TimeZone.getTimeZone("PDT")); to convert to US Pacific which was failed(not throwing any errors but converted to default ...
14
votes
2
answers
5k
views
DateTimeFormatter weekday seems off by one
I'm porting an existing application from Joda-Time to Java 8 java.time.
I ran into a problem where parsing a date/time string that contains a 'day of week' value triggered an exception in my unit ...
2
votes
2
answers
1k
views
UTC to local method in DateTimeZone of Joda-Time to Java 8
We are changing Joda-Time API's to Java 8 time API's. In Joda-Time I have used:
DateTimeZone.convertLocalToUTC(this.getMillis(), true);
DateTimeZone.convertUTCToLocal(long millis);
Can any one tell ...
10
votes
1
answer
10k
views
Joda-Time to Java 8 conversion
How can I achieve the following in Java 8 java.time:
DateTime dt = new DateTime(year, month, date, hours, min, sec, milli);
But I have found this option:
OffsetDateTime.of(year, month, dayOfMonth, ...
0
votes
0
answers
190
views
Java 8 ZonedDateTime strips off .SSS if they are zeros [duplicate]
For whatever reason, ZonedDateTime in jdk 8 is removing .SSS values from the object if they are zeros. This did not happen with joda-time's DateTime object.
String date = "2016-10-28T02:32:12.141";
...
7
votes
4
answers
14k
views
Java 8 LocalDateTime ZonedDateTime cannot parse date with time zone
I am trying to use Java 8 new Date pattern instead of Joda and I have the following problem:
Both
ZonedDateTime.parse("02/05/16 11:51.12.083 +04:30", DateTimeFormatter.ofPattern("dd/MM/yy HH:mm.ss....
15
votes
1
answer
13k
views
Get the next LocalDateTime for a given day of week
I want to create instance of LocalDateTime at the date/time of the next (for example) Monday.
Is there any method in Java Time API, or should I make calculations how many days are between current and ...
8
votes
1
answer
3k
views
Java 8: How to parse expiration date of debit card?
It is really easy to parse expiration date of debit/credit card with Joda time:
org.joda.time.format.DateTimeFormatter dateTimeFormatter = org.joda.time.format.DateTimeFormat.forPattern("MMyy")....
9
votes
1
answer
5k
views
Joda time: DateTimeComparator. What is similar in Java 8 Time Api?
With Joda Time, you are able to do a really cool things, for example:
package temp;
import org.joda.time.DateTime;
import org.joda.time.DateTimeComparator;
import org.joda.time.DateTimeFieldType;
...
11
votes
2
answers
15k
views
migrate from Joda time library to Java time (Java 8)
Our software architect made decision to remove Joda time library from our project dependencies and to use features of Java 8 time. I am doing research of our project and I am trying to find all places ...
-1
votes
5
answers
2k
views
parse armydate long number to LocalDate
I have a long number in the format:
Long l = 20151228;
And I want to parse it into LocalDate object.
How can I do that?
17
votes
1
answer
7k
views
java.time ISO date format with fixed millis digits (in Java 8 and later)
By default, the toString method of Instant uses the DateTimeFormatter.ISO_INSTANT formatter. That formatter won’t print the digits for fraction-of-second if they happen to be 0.
java-time examples:
...
3
votes
1
answer
2k
views
Best way to convert org.threeten.bp.* and org.joda.time* to corresponding java.time.* class
I am working on a project that uses a shared library which uses org.threeten for Date/Time. As the library is shared across many projects it cannot be upgraded to Java 8 yet (sigh).
The shortest way ...
23
votes
1
answer
14k
views
Java 8 Date API vs Calendar / Date / DateFormat
There is this new-n-cool Date API in Java 8, the java.time package. I understand that it is better designed, less ambiguous and more thread-safe than the old classes. Still, I am not sure how to go ...
8
votes
3
answers
2k
views
Parse ISO date by Period in Java 8
i want to replace JodaTime by Java 8 DateTime API.
I've got ISO-8601 period described = P2W5DT11H8M
In JodaTime i parse it very simply by executing the following code:
Period.parse("P2W5DT11H8M") ...
51
votes
1
answer
25k
views
Is Joda Time deprecated with java 8 Date and Time API? (java.time)
Is there any reason to use Joda Time if I can use Java 8 Date and Time API (java.time)?
Should I use Java 8 Date and Time every time?
2
votes
0
answers
3k
views
How to use properly DateTimeFormatter / convert from java.time.Instant [duplicate]
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 a very simple ...
1
vote
2
answers
2k
views
How to covert Joda-Time's DateTimeFormat.forStyle() to JSR 310 JavaTime?
I working on convertion Grails Joda-Time plugin to JavaTime.
And I've old Joda time code like this:
def style
switch (type) {
case LocalTime:
style = '-S'
...
8
votes
3
answers
8k
views
Week representation in Java 8 Time API
I would like to have a class to represent a particular week of year - for example today it's 29 November, which is exactly week number 48 of year 2014. So, one example implementation would be:
import ...
304
votes
4
answers
101k
views
Differences between Java 8 Date Time API (java.time) and Joda-Time
I know there are questions relating to java.util.Date and Joda-Time. But after some digging, I couldn't find a thread about the differences between the java.time API (new in Java 8, defined by JSR 310)...
2
votes
3
answers
584
views
java.time ::toString(String pattern) method missing
Consider the following code:
public static void main(String[] args) {
String pattern = "MMM dd, yyyy HH:mm:ss a z";
// joda-time
DateTime dt = DateTime.now();
System.out.println(dt....
78
votes
4
answers
28k
views
Is there a class in java.time comparable to the Joda-Time Interval?
I'm evaluating to migrate my project from the usage of Joda-Time to the java.time package in Java 8. In Joda-Time, I heavily used the Interval class. I could not find anything like this in java.time.
...
44
votes
5
answers
38k
views
Formatting a Duration in Java 8 / jsr310
I am transitioning a project from Joda-Time to java8's native time libraries, and I have run into a snag.
I have been unable to find a formatter for Duration. I would like to have a custom String ...
13
votes
2
answers
21k
views
How to list the timezone offset, timezone ID, and long name in Joda Time / Java 8?
Time zone ids of Joda Time can simply be displayed with the following segment of code.
Set<String> zoneIds = DateTimeZone.getAvailableIDs();
for(String zoneId:zoneIds) {
System.out.println(...