Calculating the difference between two Java date instances

I'm using Java's java.util.Date class in Scala and want to compare a Date object and the current time. I know I can calculate the delta by using getTime(): (new java.util.Date()).getTime() -...

Illegal pattern character 'T' when parsing a date string to java.util.Date

I have a date string and I want to parse it to normal date use the java Date API,the following is my code: public static void main(String[] args) { String date="2010-10-02T12:23:23Z"; String...

Sign CSR using Bouncy Castle

I cannot find any code/doc describing how to sign a CSR using BC. As input I have a CSR as a byte array and would like to get the cert in PEM and/or DER format. I have gotten this far def...

Retrieve a list of date from a SQL query

Is it possible to retrieve a List<Date> instead of a List<SomeBean> using Ebean ? For example, I have this model: Days(id, name, day); I'd like to do something like: List<Date> dates =...

JPA Entity, JSON serialization

I have my JPA Entity class, AssetOrder. And I have defined a custom JSONSerializer for another entity called Product, which is used by AssetOrder entity internally to map the productID from the...

How to properly store end date in database

Application: Java + ExtJS There are a lot of different entity with properties of java.util.Date type: startDate and iesendDate (endDate could be NULL). Both dates could be selected with or without...

Request processing failed; nested exception is java.lang.NullPointerException

i created a form and on post i want to save those values to the database and show the saved values on the page. i am new to spring mvc and hence i am not understanding where i am going wrong. Here...

JSON Serializing date in a custom format (Can not construct instance of java.util.Date from String value)

could not read JSON: Can not construct instance of java.util.Date from String value '2012-07-21 12:11:12': not a valid representation("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",...

Java Check Duplicates in data file and add number

I have data file like: First Name,Last Name,Number Robert,Thomas Jimmy,Johns Robert,Thomas Conner,Thomas Robert,Thomas Jimmy,Johns Outfile Should be like: First Name,Last...

How to use @ConstructorResult annotation

I have some native query and want to map the result of query execution into List of NON-Entity POJO classes: @SqlResultSetMapping( name = "SomeMapping", classes = { ...

Update JTable automically

How would a JTable update automatically based off of time? So every time the current time changes, the table updates automatically. Could some provide a snippet of code of how this may work in...

Swing Timer stopwatch in Java

Can someone provide me an example of a Swing Timer stopwatch GUI in Java using a constantly-updating JLabel? I am not familiar with using @Override, so please don't suggest code with that in it...

UnsupportedOperationException - Why can't you call toInstant() on a java.sql.Date?

The java.util.Date class has a method called toInstant() that converts the Date instance to a java.time.Instant. The java.sql.Date class extends the java.util.Date class, but when I attempt to...

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '5' for key 'PRIMARY'

Firtst of all, I added ten records into my databases manually. Then I ran the project, it went wrong like this: Duplicate entry '1' for key 'PRIMARY'. Then I refreshed the page nine times, it...

How to bind a Vaadin DateField to a LocalDateTime

The Vaadin docs show how to use the DateField with java.util.Date but I want to bind the DateField with a BeanFieldGroup to a bean property of Java 8 type java.time.LocalDateTime. How can I achieve that?

How to implement Role Permission based system in Spring Boot

I am trying to implement role permissions based system using spring boot and spring security. For this, I have taken an example from...

OpenCSV not mapping JavaBeans with annotations

I am using version 3.8 of OpenCSV library. I am using annotation to map the bean fields to the columns in the CSV file. I have it working to a point. It is failing when a date field is...

Swagger Codegen Java client Date format

I have a java client in swagger who's swagger.json includes the following: "updatedTime":{"type":"string","format":"date-time"} This issue from 2015 says specifying the format as date-time...

404 Not Found: Something wrong with access to a servlet deployed on Tomcat

I followed a very simple example from Head First Servlets & JSP at beginning, but I encountered a problem. When I tried to access a servlet named Ch1Servlet in webapps/ch1/web-inf/, mapped onto...

Field in com.XXX required a bean of type that could not be found

I'm working on Spring over Hibernate project an i'm only in the beginning. I'm tryng to hav a SpringBootApplication which writes to MsSql some LogEntries objects. I have some different...

compile gradle task is always executed

I have a multidex project with minSDK 21, using gradle 4.5.1 and gradle plugin 3.0.1. My issue is that even without any source file change when I try to assemble and deploy to a phone the compile...

Could not open JDBC Connection for transaction

I would like to report a configuration problem that seems strange to me. Here's the application context configuration file I'm using <beans xmlns="http://www.springframework.org/schema/beans" ...

Postgres Sql `could not determine data type of parameter` by Hibernate

I have JpaRepository: @Repository public interface CardReaderRepository extends JpaRepository<CardReaderEntity, Integer > { } when i execute query in this repo same as this: @Query( value =...

I am retriveing my insert function in database helper class in another class but when i run app it shows null exception

On clicking a button In which I am Retrieving inserted data. But it shows null pointer Exception. My app should show inserted data and the user enters data and time in an alert dialog box. But...

Create actual date in string format from microseconds with precision of microseconds

I want to create a java.util.Date object from microseconds. But i don't want to lose its precision microseconds to millisecond. Currently i am converting microseconds to Date object in the...

How to attach screenshot to Extent Report in java selenium

I am trying to attach screenshot for failed testcases from my path to Extent Report but somehow i am not able to attach into it. I have tried my possible solution but it fails . I have used extent...

Getting the UTC timestamp in Java

An old Stack Overflow posting suggests that the way to get the UTC timestamp in Java is the following: Instant.now() // Capture the current moment in UTC. Unfortunately this does not work for...

How to create immutable object from mutable in java?

How to create immutable Planet so the name doesn't change? I am struggling as I think it is immutable project with mutable object. Correct me if I am wrong. Every time I change name in the output...

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "_pkey"

I get this error when I try to update two entity with relanshionship one-to-many. This is first entity class: package com.example.demo.entity; import javax.persistence.Column; import...

Why do HashSets behave differently in Java 8 and Java 9+?

When trying to remove objects wrapped in iterator Java 8 and Java 9+ behave differently. Consider the following example: import java.util.Date; import java.util.HashSet; import...