| |

VerySource

 Forgot password?
 Register
Search
View: 717|Reply: 4

Ask a question about automatic detection time expiration in the database

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-17 13:20:01
| Show all posts |Read mode
I am currently working on a house rental system. When users release house information, they need to fill in a valid time for the house. For example, today is the 2nd, assuming it expires on the 10th. The house information is stored in the database after submission. Does the house expire? (Regardless of whether the house is rented) ... Is it using the database itself or in the code ???? Please give pointers to seniors ...
Thanks a lot
Reply

Use magic Report

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

Post time: 2020-2-8 19:15:01
| Show all posts
Look at this class, you can get how good the number is n days later, and then use comparTo (Date date) to compare it with the day you arrived.
package com.group.page;

import java.sql.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;

public class DateAdd {
/ **
* Calculate the date after n days from today
* /
public static Date dateAdd (int last) throws Exception {
boolean count = true;
//java.util package, set the current time
Calendar strDate = Calendar.getInstance ();
// Date minus if not minus will change the month // Generate (year-month-day)
strDate.add (strDate.DATE, last);
String meStrDate = strDate.get (strDate.YEAR)
+ "-" + String.valueOf (strDate.get (strDate.MONTH) +1)
+ "-" + strDate.get (strDate.DATE);
SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd");
java.util.Date mydate = format.parse (meStrDate);
Date nextDate = new Date (mydate.getTime ());
return nextDate;
        }

}
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-27 21:00:01
| Show all posts
Is there any other way,
Can this make the database automatically detect the expiration date ,,,,
It is best to automatically detect ,,,
Reply

Use magic Report

1

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-3 22:15:01
| Show all posts
Can you elaborate more on the demand? I understand poorly

But there should be many ways to solve
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-6 16:30:01
| Show all posts
Ok, let me talk about it in more detail. For example, I posted a rental house information, which will be valid for one week from today. After the release, the house information will be stored in the database, so how can the system (or database) judge my house Has the information expired? Is it always checking all the house information in the database, or are there other methods?
It is to let the system (or database) automatically delete the expired house information (or other operations) ,,,,,
Can everyone understand this way?
In a hurry ...........................
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