15-determine whether the date entered by the user is the current date (string processing)

Source: Internet
Author: User

Stringutil. Java

Package COM. LH. bean; import Java. util. calendar; public class stringutil {// Date entered by the user: Private string datestr; // determines whether it is today's private Boolean today; // The message private string cue; Public stringutil () {} Public String getdatestr () {return datestr;} public void setdatestr (string datestr) {// Replace the space in the date with "" datestr = datestr. replaceall ("", ""); this. datestr = datestr;} public Boolean istoday () {// splits the date string into an array string datearr [] = Datestr. split ("-"); int year = integer. parseint (datearr [0]); int month = integer. parseint (datearr [1]); int date = integer. parseint (datearr [2]); // obtain the calender object calendar now = calendar for the current system time. getinstance (); int nowyear = now. get (now. year); int nowmonth = now. get (now. month) + 1; int nowdate = now. get (now. day_of_month); If (year = nowyear & month = nowmonth & date = nowdate) {// if the values of year, month, and day are the same, cue = "the input date is Current date! "; Today = true;} else {cue =" the input date is not the current date! "; Today = false;} return today;} Public String getcue () {return cue;} public void setcue (string cue) {This. cue = cue;} public void settoday (Boolean today) {This. today = today ;}}

Index. jsp

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <HTML> 

Check. jsp

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <HTML> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.