Commit 4e7b9ccdd3852a793571eb8d395673b20c467fee
1 parent
1e13e303
Exists in
master
Formatação de datas.
Showing
1 changed file
with
12 additions
and
3 deletions
Show diff stats
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/component/Util.java
1 | package br.com.eselo.component; | 1 | package br.com.eselo.component; |
2 | 2 | ||
3 | +import java.security.Timestamp; | ||
3 | import java.text.DateFormat; | 4 | import java.text.DateFormat; |
4 | import java.text.Normalizer; | 5 | import java.text.Normalizer; |
5 | import java.text.SimpleDateFormat; | 6 | import java.text.SimpleDateFormat; |
6 | import java.text.Normalizer.Form; | 7 | import java.text.Normalizer.Form; |
7 | import java.text.ParseException; | 8 | import java.text.ParseException; |
9 | +import java.time.ZoneOffset; | ||
10 | +import java.time.ZonedDateTime; | ||
11 | +import java.time.format.DateTimeFormatter; | ||
12 | +import java.time.temporal.ChronoUnit; | ||
13 | +import java.time.temporal.TemporalAccessor; | ||
8 | import java.util.Date; | 14 | import java.util.Date; |
9 | import java.util.Locale; | 15 | import java.util.Locale; |
10 | import java.util.regex.Pattern; | 16 | import java.util.regex.Pattern; |
@@ -36,8 +42,11 @@ public class Util { | @@ -36,8 +42,11 @@ public class Util { | ||
36 | } | 42 | } |
37 | 43 | ||
38 | public static String dataHoraAtual() { | 44 | public static String dataHoraAtual() { |
39 | - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
40 | - return dateFormat.format(new Date()); | 45 | + //DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ssZ"); |
46 | + //dateFormat.format(new Date()); | ||
47 | + return ZonedDateTime.now( ZoneOffset.UTC ) | ||
48 | + .truncatedTo( ChronoUnit.SECONDS ) | ||
49 | + .format( DateTimeFormatter.ISO_DATE_TIME ); | ||
50 | + | ||
41 | } | 51 | } |
42 | - | ||
43 | } | 52 | } |