Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
m3104-tp4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amaury Vanoorenberghe
m3104-tp4
Commits
04c2fe5c
Commit
04c2fe5c
authored
3 years ago
by
Amaury Vanoorenberghe
Browse files
Options
Downloads
Patches
Plain Diff
EX - Ajout de la servlet NouvelAn
parent
1bbb91dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/NouvelAn.java
+29
-0
29 additions, 0 deletions
src/NouvelAn.java
with
29 additions
and
0 deletions
src/NouvelAn.java
0 → 100644
+
29
−
0
View file @
04c2fe5c
import
java.io.*
;
import
java.util.*
;
import
javax.servlet.*
;
import
javax.servlet.http.*
;
import
javax.servlet.annotation.WebServlet
;
import
java.time.*
;
import
java.time.temporal.*
;
@WebServlet
(
"/NouvelAn"
)
public
class
NouvelAn
extends
HttpServlet
{
public
void
service
(
HttpServletRequest
req
,
HttpServletResponse
res
)
throws
ServletException
,
IOException
{
res
.
setContentType
(
"text/html;charset=UTF-8"
);
PrintWriter
out
=
res
.
getWriter
();
out
.
println
(
"<head><title>Nouvel an</title>"
);
out
.
println
(
"<META content=\"charset=UTF-8\"></head><body>"
);
out
.
println
(
"<center>Nouvel an</center>"
);
LocalDateTime
today
=
LocalDateTime
.
now
();
LocalDateTime
januaryFirst
=
LocalDateTime
.
of
(
today
.
getYear
()
+
1
,
Month
.
JANUARY
,
1
,
0
,
0
);
Duration
delay
=
Duration
.
between
(
today
,
januaryFirst
);
long
seconds
=
delay
.
get
(
ChronoUnit
.
SECONDS
);
out
.
println
(
String
.
format
(
"Il reste %d secondes avant le nouvel an..."
,
seconds
));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment