localdate

Java LocalDate Formatting of 2000-1-2 error [duplicate]

自作多情 提交于 2019-12-17 17:12:29
问题 This question already has answers here : Java string to date conversion (13 answers) SimpleDateFormat incorrectly rolling year forward during format of Date [duplicate] (2 answers) Closed last year . Today some tests on a new build machine failed, where on other machines thes where ok. Looking after the problem it shows that @Test public void testDateTimeFormater() { String result = LocalDate.of(2000,1,2) .format(DateTimeFormatter.ofPattern("YYYY-MM-dd")); Assert.assertTrue(result,result

Why does JS assume string date without time is UTC if 0 padded and local if not padded? [duplicate]

流过昼夜 提交于 2019-12-12 14:06:01
问题 This question already has answers here : Why does Date.parse give incorrect results? (11 answers) Closed last year . This is a bizarre but I'm sure there's a perfectly good explanation. My team and I recently discovered when using java's LocalDate and sending it back to the frontend with the default string format "YYYY-MM-DD" , Javascript will automatically create a date assuming that the string was UTC, so living in ET zone, it automatically subtracts -5 hours. Annoying, but we get it.

Java: Unable to obtain LocalDate from TemporalAccessor

烈酒焚心 提交于 2019-12-12 10:41:34
问题 I am trying to change the format of a String date from EEEE MMMM d to MM/d/yyyy by, first, converting it into a LocalDate and then applying a formatter of a different pattern to the LocalDate before parsing it into String again. Here's my code: private String convertDate(String stringDate) { //from EEEE MMMM d -> MM/dd/yyyy DateTimeFormatter formatter = new DateTimeFormatterBuilder() .parseCaseInsensitive() .append(DateTimeFormatter.ofPattern("EEEE MMMM d")) .toFormatter(); LocalDate

Ajax response does not parse LocalDate

怎甘沉沦 提交于 2019-12-12 03:44:28
问题 I need to pass Localdate as part of the Ajax response to jquery datatables. LocalDate field does not display its value. Instead it prints [object,Object]. Obviously, it means LocalDate was not deserialized. Can some one please explain how to deserialize Localdate to display it properly. Below is my Jquery Code: var table = $("#example").DataTable({ "bProcessing" : true, "bServerSide" : true, "sAjaxSource" : "jsonSource.web", "aoColumns" : [ { "mData" : "name" }, { "mData" : "position" }, {

How do you get Grails gsp support for Java localdatetime

十年热恋 提交于 2019-12-11 20:39:25
问题 I am running Grails 3.3.8 with Java 8.v181. I have a included hibernate-java8 and grails-java8 plugins, in build.gradle //needed for java local datetime features set compile "org.grails.plugins:grails-java8" compile "org.hibernate:hibernate-java8" I have a domain class like this import cmdb.Customer import java.time.LocalDateTime class ServiceRequest { //Long id String requestIdentifier Customer customer String customerSummary String status LocalDateTime dateCreated = LocalDateTime.now()

Implicit parse LocalDate with Post @Consumes(MediaType.ApplicationJson)

半腔热情 提交于 2019-12-11 02:36:51
问题 this is my Endpoint in which I would like to add a "Firma" with a post request, but the JSON cannot implicit parse the timestamp . @POST @Consumes(MediaType.APPLICATION_JSON) public Response addFirma(Firma firma){ firmaFacade.create(firma); return Response.ok().build(); } Those are the variables of "Firma" private int firm1; private LocalDate firm2; And this is the JSON-String I sent - LocalDate is NULL { "firm1":2, "firm2":"2017-09-09" } But whenever I use the get Request with test data, it

Why LocalDate.plusDays not working here?

99封情书 提交于 2019-12-11 02:02:37
问题 I'm trying to split a date range into individual dates in the following way: private static void splitDates(LocalDate dateFrom, LocalDate dateTo) { while (dateFrom.isBefore(dateTo) || dateFrom.isEqual(dateTo)) { System.out.println(dateFrom); dateFrom.plusDays(1L); } } And I don't know why dateFrom.plusDays(1L) is not working as the date remains still the same so the loop becomes infinite. 回答1: plusDays doesn't alter the original LocalDate , you have to assign the result : dateFrom = dateFrom

Difference between two DateTime objects in minutes

我怕爱的太早我们不能终老 提交于 2019-12-10 22:02:32
问题 =========================================================== Date_Time_from | Date_Time_to =========================================================== 2018-06-16 02:00:00 |2018-06-18 02:00:00 2018-06-16 03:00:00 |2018-06-18 03:00:00 2018-06-16 04:00:00 |2018-06-18 04:00:00 2018-06-16 05:00:00 |2018-06-18 05:00:00 2018-06-16 06:00:00 |2018-06-18 06:00:00 ========================================================== I am using LocalDateTime but instead of getting the difference of 2 DateTime , it

Date issue in spring boot data rest

亡梦爱人 提交于 2019-12-10 15:17:26
问题 I'm having a problem with spring data rest when I'm handling dates. In a brief, it is delaying the date in one day. For example, if I have 1111-11-11 it returns to me 1111-11-10. There are some related post here in SO (ex1, ex2, ex3), but none of them solved the problem. I have an entity with this LocalDate : @Column(nullable=true) private LocalDate birthDate; I also have this repository: @RepositoryRestResource(collectionResourceRel = "person", path = "person") public interface

Year changing from negative -509 to a positive 510 in JDBC with H2 Database

走远了吗. 提交于 2019-12-10 13:14:45
问题 -509 vs 510 I am seeing some kind of altered or erroneous data, with the use of JDBC. So I observe using H2 Database version 1.4.196 on Java 8 Update 151. Here is a complete example. Note how we retrieve the date value three times, first as a LocalDate object, secondly as text, and thirdly as an int year number extracted from a cast LocalDate object. In the text version we can see that the year is indeed negative. Mysteriously the LocalDate has a different year number and it is positive