| |

VerySource

 Forgot password?
 Register
Search
View: 710|Reply: 2

Questions about JAVA.SQL.DATE in the STRUTS + HIBERNATE architecture ??

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-5 12:00:01
| Show all posts |Read mode
In the initial use of STRUTS + HIBERNATE architecture, I used the data table class automatically generated by MECCLIPSE, where the DATE type data was initialized to JAVA.UTIL.DATE type. After I took out an instance using the FINDBYID method, it returned the DATE field corresponding to the instance. The value is JAVA.UTIL.DATE type, which is displayed in the form of "1990-11-11 00: 00: 00.0" on the interface, but this format does not conform to the database DATE type specification. An error will be reported when writing the database. The DATE type has no subsequent time, only the date, and simple processing can truncate strings, but I think this architecture should not solve this problem, otherwise it will become more complicated.
How do you solve this problem in general?
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-23 10:18:01
| Show all posts
It is a bit different for the date type in the database and the Date in java.
As for the problem between these two, I have not been able to solve it.
However, I converted Date to String using DateFormat and then inserted it into the database (of course, the database is also a string)
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-1-24 21:54:01
| Show all posts
Convert DB's DATE type data to JAVA.UTIL.TimeStamp type (you can change it yourself when it is automatically generated), and you're done
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list