Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meet-us
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
Model registry
Operate
Environments
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
marc.vachon
meet-us
Commits
d3e7e97b
Commit
d3e7e97b
authored
6 years ago
by
marc.vachon
Browse files
Options
Downloads
Patches
Plain Diff
Change date format
parent
40c4dc98
Branches
date_format
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Appointment.java
+2
-22
2 additions, 22 deletions
src/Appointment.java
src/Meeting.java
+18
-15
18 additions, 15 deletions
src/Meeting.java
src/MyDate.java
+7
-17
7 additions, 17 deletions
src/MyDate.java
src/User.java
+2
-1
2 additions, 1 deletion
src/User.java
with
29 additions
and
55 deletions
src/Appointment.java
+
2
−
22
View file @
d3e7e97b
...
...
@@ -17,10 +17,7 @@ public class Appointment {
System
.
out
.
println
(
"--------------------------------------------------"
);
System
.
out
.
println
(
"Calcul de la date et heure idéal..."
);
this
.
most_popular_date
();
System
.
out
.
println
(
"Rendez-vous fixé le: "
+
this
.
f_date
.
get_day
()
+
"/"
+
this
.
f_date
.
get_month
()
+
"/"
+
this
.
f_date
.
get_year
());
System
.
out
.
println
(
"Rendez-vous fixé le: "
+
this
.
f_date
.
get_date
().
toString
());
System
.
out
.
println
(
"Fini"
);
}
...
...
@@ -37,7 +34,7 @@ public class Appointment {
for
(
MyDate
date1:
this
.
t_date
){
for
(
MyDate
date2:
this
.
t_date
){
if
(
compare_date
(
date1
,
date
2
))
if
(
date1
.
get_date
().
equals
(
date2
.
get_
date
()
))
c
++;
}
// if date's most popular
...
...
@@ -54,21 +51,4 @@ public class Appointment {
for
(
MyDate
d:
this
.
t_date
){
}
}
/**
* Compare 2 dates
* @param d1 Date format, first date
* @param d2 Date format, second date
* @return true if dates are the same
*/
private
Boolean
compare_date
(
MyDate
d1
,
MyDate
d2
){
if
(
d1
.
get_day
()
==
d2
.
get_day
()){
if
(
d1
.
get_month
()
==
d2
.
get_month
()){
if
(
d1
.
get_year
()
==
d2
.
get_year
()){
return
true
;
}
}
}
return
false
;
}
}
This diff is collapsed.
Click to expand it.
src/Meeting.java
+
18
−
15
View file @
d3e7e97b
...
...
@@ -7,13 +7,16 @@ import java.text.SimpleDateFormat;
public
class
Meeting
{
private
static
ArrayList
<
User
>
table_User
;
private
static
SimpleDateFormat
parseDate
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
table_User
=
new
ArrayList
<
User
>();
String
date
=
"14/03/2019"
;
System
.
out
.
println
(
date_validity
(
date
));
System
.
out
.
println
(
date_validity
(
parseDate
.
parse
(
date
))
)
;
Date
d1
=
new
Date
(
2019
,
3
,
21
);
System
.
out
.
println
(
parseDate
.
format
(
d1
));
set_t_user
();
...
...
@@ -56,7 +59,7 @@ public class Meeting{
System
.
out
.
println
(
"Utilisateur :"
);
System
.
out
.
println
(
"Coordonées x, y: "
+
user
.
get_location
().
get_x
()
+
", "
+
user
.
get_location
().
get_y
());
System
.
out
.
println
(
"Date possible :"
);
user
.
get_calendar
().
forEach
((
d
)
->
System
.
out
.
println
(
d
.
get_day
()
+
"/"
+
d
.
get_month
()
+
"/"
+
d
.
get_year
(
)));
user
.
get_calendar
().
forEach
((
d
)
->
System
.
out
.
println
(
parseDate
.
format
(
d
.
get_date
()
)));
System
.
out
.
println
();
}
...
...
@@ -67,7 +70,7 @@ public class Meeting{
private
static
void
print_calendar
(
ArrayList
<
MyDate
>
cal
){
System
.
out
.
println
(
"--------------------------------------------------"
);
System
.
out
.
println
(
"General calendar"
);
cal
.
forEach
((
d
)
->
System
.
out
.
println
(
d
.
get_day
()
+
"/"
+
d
.
get_month
()
+
"/"
+
d
.
get_year
(
)));
cal
.
forEach
((
d
)
->
System
.
out
.
println
(
parseDate
.
format
(
d
.
get_date
()
)));
System
.
out
.
println
(
"Fini"
);
}
...
...
@@ -76,7 +79,7 @@ public class Meeting{
* their location,
* their calendar
*/
private
static
void
set_t_user
(){
private
static
void
set_t_user
()
throws
Exception
{
System
.
out
.
println
(
"Bonjour, veuillez entrer les informations utilisateur:"
);
boolean
end
=
false
;
...
...
@@ -106,26 +109,26 @@ public class Meeting{
* Set table of date's user
* @return ArrayList of date
*/
private
static
ArrayList
<
MyDate
>
set_date
(){
private
static
ArrayList
<
MyDate
>
set_date
()
throws
Exception
{
ArrayList
<
MyDate
>
t_date
=
new
ArrayList
<
MyDate
>();
boolean
end
=
false
;
Scanner
sc
=
new
Scanner
(
System
.
in
);
while
(!
end
){
System
.
out
.
println
(
"Date possible (jour/mois heure:min heure:min):"
);
System
.
out
.
println
(
"Date possible (jour/mois
/année
heure:min heure:min):"
);
String
[]
line
=
sc
.
nextLine
().
split
(
" "
);
if
(
line
.
length
==
3
){
String
[]
date
=
line
[
0
].
split
(
"/"
);
//String[] date = line[0].split("/");
String
[]
from
=
line
[
1
].
split
(
":"
);
String
[]
to
=
line
[
2
].
split
(
":"
);
System
.
out
.
println
(
"Vous avez saisi : "
+
date
[
0
]
+
"/"
+
date
[
1
]
+
"/2019 de "
+
System
.
out
.
println
(
"Vous avez saisi : "
+
line
[
0
]
+
" de "
+
from
[
0
]
+
":"
+
from
[
1
]
+
" à "
+
to
[
0
]
+
":"
+
to
[
1
]);
MyDate
d
=
new
MyDate
(
new
int
[]{
Integer
.
parseInt
(
date
[
0
]),
Integer
.
parseInt
(
dat
e
[
1
]),
2019
},
MyDate
d
=
new
MyDate
(
parseDate
.
parse
(
lin
e
[
0
]),
new
int
[]{
Integer
.
parseInt
(
from
[
0
]),
Integer
.
parseInt
(
from
[
1
])},
new
int
[]{
Integer
.
parseInt
(
to
[
0
]),
Integer
.
parseInt
(
to
[
1
])});
...
...
@@ -168,14 +171,14 @@ public class Meeting{
return
calendar
;
}
private
static
Boolean
date_validity
(
String
d1
){
private
static
Boolean
date_validity
(
Date
d1
){
Boolean
error
=
false
;
Date
d2
=
new
Date
();
// this object contains the current date value
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
);
Date
date
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
).
parse
(
d1
);
return
new
Date
().
before
(
date
);
//Date date = new SimpleDateFormat("dd/MM/yyyy").parse(d1);
return
d2
.
before
(
d1
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
src/MyDate.java
+
7
−
17
View file @
d3e7e97b
import
java.util.Date
;
public
class
MyDate
{
private
int
day
;
private
int
month
;
private
int
year
;
private
Date
date
;
private
Time
from
;
private
Time
to
;
public
MyDate
(
int
[]
date
,
int
[]
from
,
int
[]
to
){
this
.
day
=
date
[
0
];
this
.
month
=
date
[
1
];
this
.
year
=
date
[
2
];
public
MyDate
(
Date
date
,
int
[]
from
,
int
[]
to
){
this
.
date
=
date
;
this
.
from
=
new
Time
(
from
[
0
],
from
[
1
]);
this
.
to
=
new
Time
(
to
[
0
],
to
[
1
]);
}
public
int
get_day
(){
return
this
.
day
;
}
public
int
get_month
(){
return
this
.
month
;
}
public
int
get_year
(){
return
this
.
year
;
public
Date
get_date
(){
return
this
.
date
;
}
public
int
[]
get_t_from
(){
...
...
This diff is collapsed.
Click to expand it.
src/User.java
+
2
−
1
View file @
d3e7e97b
import
java.util.*
;
import
java.net.*
;
import
java.io.*
;
import
java.util.Date
;
public
class
User
{
...
...
@@ -51,7 +52,7 @@ public class User {
* @param from int[]
* @param to int[]
*/
public
void
add_Date
(
int
[]
date
,
int
[]
from
,
int
[]
to
){
public
void
add_Date
(
Date
date
,
int
[]
from
,
int
[]
to
){
MyDate
d
=
new
MyDate
(
date
,
from
,
to
);
this
.
calendar
.
add
(
d
);
}
...
...
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