localdate

How to send Date in REST API in POST method

狂风中的少年 提交于 2019-12-10 09:20:38
问题 I am trying to build RESTful web service with Spring support. I am getting following exception when I am trying to send POST request. Input: POST http://localhost:8080/InventoryDemo/item In JSON Payload: {"materialId":"ID02","materialName":"Material_2","materialCategory":"LIQUID","currency":"RUPEES","unitCostInCurrency":2200.0,"quantityLevel":1000,"quantityAtDate":"2016-04-11","warehouseName":"WareHouse_2"} Exception: WARNING: Handler execution resulted in exception: Could not read document:

Unexpected date calculation result

那年仲夏 提交于 2019-12-10 03:14:46
问题 I have a method to view a calendar in Java that calculates the date by year, day of the week and week-number. Now when I calculates the dates from 2017 everything works. But when I calculates the dates from January 2018 it takes the dates of year 2017. My code looks like import java.time.temporal.IsoFields; import java.time.temporal.ChronoField; import java.time.LocalDate; // ..... LocalDate desiredDate = LocalDate.now() .with(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1) .with(ChronoField.DAY_OF

Different behavior of WeekFields on JVM 8 and JVM 10

故事扮演 提交于 2019-12-09 08:09:02
问题 I have really simple program here: public static void main(String[] args) { LocalDate year = LocalDate.ofYearDay(2022, 100); System.out.println(year); System.out.println(WeekFields.of(Locale.GERMAN).weekOfYear()); System.out.println(year.with(WeekFields.of(Locale.GERMAN).weekOfYear(), 0)); System.out.println(year.with(WeekFields.of(Locale.GERMAN).weekOfYear(), 0).with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))); } But it behaves differently on JVM 8 and JVM 10. The problem seems to

java 8 datatime parse error

安稳与你 提交于 2019-12-09 03:25:30
问题 I am trying to convert a string to LocalDate object. but I get the following error. private LocalDate getLocalDate(String year) { String yearFormatted = "2015-01-11"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM-dd"); LocalDate dateTime = LocalDate.parse(yearFormatted, formatter); return dateTime; } here is the error Caused by: java.time.format.DateTimeParseException: Text '2015-01-11' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {DayOfMonth=11,

LocalDate minus a Period get wrong result

回眸只為那壹抹淺笑 提交于 2019-12-04 12:15:43
问题 LocalDate minus a Period (like "28 years, 1 months and 27 days"),get wrong result. But minus a Period (only have days unit ,like "10282"days) get right result. Is there anything to notice? public static void main(String[] args) { printAgeAndBirthday(1989, 2, 22); printBirthdayFromPeriod(28, 1, 27); } private static void printBirthdayFromPeriod(int years, int months, int days) { final Period period = Period.of(years, months, days); final LocalDate now = LocalDate.now(); final LocalDate

Convert LocalDate in DD/MM/YYYY LocalDate [duplicate]

烈酒焚心 提交于 2019-12-02 19:22:19
问题 This question already has answers here : SimpleDateFormat ignoring month when parsing (4 answers) Java date format conversion - getting wrong month (8 answers) Closed 9 months ago . I have a String with DD/MM/YYYY date format, and I want to check if the new date is older than today . I use LocalDate.now(); However, i have an exception when I run this code: LocalDate today = LocalDate.now(); DateTimeFormatter FORMATO_DIA = DateTimeFormatter.ofPattern("dd/mm/yyyy"); String otherDay = "02/12

Save a formatted String to a LocalDate

六月ゝ 毕业季﹏ 提交于 2019-12-02 15:41:01
问题 I have a DateConverter class: public class DateConverter extends StringConverter<LocalDate> { String pattern = "EEE, dd. MM. uuuu"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern,Locale.US); @Override public String toString(LocalDate object) { try { return formatter.format(object); } catch(Exception ex) { return ""; } } @Override public LocalDate fromString(String string) { try { return LocalDate.parse(string, formatter); } catch(Exception ex) { return null; } } public

How to enter a LocalDate value into BlueJ “Create Object” dialog box

末鹿安然 提交于 2019-12-02 10:59:32
问题 I'm not trying to format the date in YYYY-MM-DD or dd/MM/YYYY. I'm asking about the literal format of LocalDate. I just started learning Java and I am using this IDE called BlueJ. and I want to create a test method. The screenshot will show what I am trying to do Now since from the constructor we know that it requires a int, LocalDate and a double. I've searched online and found that https://www.javabrahman.com/java-8/java-8-working-with-localdate-localtime-localdatetime-tutorial-with

Convert LocalDate in DD/MM/YYYY LocalDate [duplicate]

烂漫一生 提交于 2019-12-02 10:18:25
This question already has an answer here: SimpleDateFormat ignoring month when parsing 4 answers Java date format conversion - getting wrong month 8 answers I have a String with DD/MM/YYYY date format, and I want to check if the new date is older than today . I use LocalDate.now(); However, i have an exception when I run this code: LocalDate today = LocalDate.now(); DateTimeFormatter FORMATO_DIA = DateTimeFormatter.ofPattern("dd/mm/yyyy"); String otherDay = "02/12/1995"; LocalDate otherDay2 = LocalDate.parse(otherDay, FORMATO_DIA); if (today.isBefore(otherDay2)){ System.out.println("NICE"); }

How to enter a LocalDate value into BlueJ “Create Object” dialog box

这一生的挚爱 提交于 2019-12-02 08:05:19
I'm not trying to format the date in YYYY-MM-DD or dd/MM/YYYY. I'm asking about the literal format of LocalDate. I just started learning Java and I am using this IDE called BlueJ. and I want to create a test method. The screenshot will show what I am trying to do Now since from the constructor we know that it requires a int, LocalDate and a double. I've searched online and found that https://www.javabrahman.com/java-8/java-8-working-with-localdate-localtime-localdatetime-tutorial-with-examples/ java.time.LocalDate: A LocalDate instance holds a date without a time zone, in ISO-86011 calendar