I have a string input of weekdays in German and need to get the next Localdate after today which corresponds to the given weekday string. If for example the input is Montag (Monday) I need the output as Localdate of 2022-05-16 which is the next Monday after today. If the input was in english I could do something like: Is
Tag: localdate
How to get the next n fridays which are the first, second or third friday in a month?
I need to find the next n Fridays but want to exclude 4th and possibly 5th Fridays, i.e I want to get the next n Fridays which are 1st, 2nd or 3rd of each month. I have found a way to stream over the next n Fridays (example next 10 Fridays): Output: But I need to exclude for example 2021-10-22
How to filter an array of objects by month and year – Java
I’m new at Java and I have a question. I have this array of objects: That contains this: I would like to know how can I filter this array by month and year. A first example would be filter the array by month 10 and year 2021. Any suggestion ? Answer You can use the Stream API to do it
Convert LocalDateTime UTC to Europe/Rome gave me wrong result
I tried to search for the same problem but didn’t find what I’m doing wrong. I need to convert a UTC LocalDateTime to a Europe/Rome LocalDateTime. I’m following this approach that I found on SO but I’m having a wrong result: I’m expecting the “converted time” to be 17:00 but I’m having this result. Thanks Answer I’m expecting the “converted
How to find the day when year, month and date is given?
I need a solution to return day (Monday,Tuesday…), when i have inputs like YEAR, MONTH, DATE. Answer Using the parameters, create a LocalDate from which you can get the weekday. Output: Learn more about the the the modern date-time API* from Trail: Date Time. * For any reason, if you have to stick to Java 6 or Java 7, you
How to get corresponding quarter of previous year in Scala
I have a date string with me in the format – “20202” [“yyyyQ”]. Is there a way to get the corresponding quarter of previous year ? ex- for 20202 , it should be 20192 Answer An alternative to the other answers is using my lib Time4J and its class CalendarQuarter. Example: Two main advantages of this solution are: Calendar quarters
make picocli parse local date format
PicoCLI accepts 2019-04-26 as input for a LocalDate variable, but it does not accept the German Date format like 26.04.2019. For that you need: How do you tell to PicoCLI to use this formatter and not depend on US date input? Answer You can define a custom type converter, either for a specific option, or globally for all options and
Use DateTimeFormatterBuilder for parsing dates of missing day and default to end of month
I need to parse dates in various formats. Some of these are missing the “day”. Now I want to default to end of month. I am not sure if there is a direct way where we can default to end of month But if not, how can I know that the original date was missing the day (or that a
How to parse time based tokens in java ?(1m 1M 1d 1Y 1W 1S)
I gets following strings from FE: It corresponds to 1 minute, 5 months,3 days, 30 minutes, 2 hours, 1 year, 3 weeks. Is there mean in java to parse it? I want to manipulate(add/minus) with Instant(or LocalDatetTime). Is there way to do it in java? Answer Period & Duration I consider the following solution simple and pretty general (not fully