FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaExercises/Experiments/DateAndTimeParsing.java at master · biblelamp/JavaExercises · GitHub
biblelamp
/
JavaExercises
Public
Notifications
You must be signed in to change notification settings
Fork
130
Star
153
Code
Issues
1
Pull requests
9
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaExercises
/
Experiments
/
DateAndTimeParsing.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (24 loc) · 1.01 KB
Breadcrumbs
JavaExercises
/
Experiments
/
DateAndTimeParsing.java
Copy path
File metadata and controls
30 lines (24 loc) · 1.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import
java
.
util
.
Date
;
import
java
.
util
.
Locale
;
import
java
.
text
.
ParseException
;
import
java
.
text
.
DateFormat
;
import
java
.
text
.
SimpleDateFormat
;
import
java
.
time
.
LocalDate
;
import
java
.
util
.
concurrent
.
TimeUnit
;
/*
* Parsing different type od date
* see https://stackoverflow.com/questions/4496359/how-to-parse-date-string-to-date
*/
class
DateAndTimeParsing
{
public
static
void
main
(
String
[]
args
)
throws
ParseException
{
DateFormat
df
=
new
SimpleDateFormat
(
"(HH:mm a EEE, MMM dd, yyyy)"
,
Locale
.
ENGLISH
);
Date
date
=
df
.
parse
(
"(3:39 PM Friday, December 20, 2002)"
);
System
.
out
.
println
(
date
);
System
.
out
.
println
(
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
).
format
(
date
));
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"d.M.yyy"
);
System
.
out
.
println
(
dateFormat
.
format
(
java
.
sql
.
Date
.
valueOf
(
LocalDate
.
of
(
2821
,
1
,
1
))));
Date
now
=
new
Date
();
System
.
out
.
println
(
now
);
System
.
out
.
println
(
new
Date
(
now
.
getTime
() +
TimeUnit
.
MINUTES
.
toMillis
(
1
)));
}
}
Back
|
FazBrowse Home
|
New Git URL