Skip to content

Commit 519f986

Browse files
Correcao da busca por data
1 parent baf95fd commit 519f986

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

testeSantanderWay/src/main/java/br/com/testesantanderway/TesteSantanderWayApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
@EnableSpringDataWebSupport
1313
@EnableCaching
1414
public class TesteSantanderWayApplication {
15-
@PostConstruct
16-
void started(){
17-
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
18-
}
15+
// @PostConstruct
16+
// void started(){
17+
// TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
18+
// }
1919

2020
public static void main(String[] args) {
2121
SpringApplication.run(TesteSantanderWayApplication.class, args);

testeSantanderWay/src/main/java/br/com/testesantanderway/controller/GastosController.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@
55
import br.com.testesantanderway.dto.GastosDTO;
66
import br.com.testesantanderway.modelo.Gasto;
77
import br.com.testesantanderway.repository.GastoRepository;
8-
import br.com.testesantanderway.util.UtilDate;
98
import org.springframework.beans.factory.annotation.Autowired;
109
import org.springframework.cache.annotation.Cacheable;
1110
import org.springframework.data.domain.Page;
1211
import org.springframework.data.domain.Pageable;
1312
import org.springframework.data.domain.Sort;
1413
import org.springframework.data.web.PageableDefault;
15-
import org.springframework.format.annotation.DateTimeFormat;
1614
import org.springframework.http.ResponseEntity;
1715
import org.springframework.web.bind.annotation.*;
1816
import org.springframework.web.util.UriComponentsBuilder;
1917

2018
import java.net.URI;
21-
import java.time.LocalDateTime;
22-
import java.util.Date;
2319
import java.util.Optional;
2420

2521
@RestController
@@ -55,8 +51,7 @@ public ResponseEntity<GastosDTO> lancarGastos(@RequestBody GastoForm form, UriCo
5551
}
5652

5753
@GetMapping("/{dataCriacao}")
58-
public ResponseEntity<DetalheGastosDTO> detalheGastosPorData(@PathVariable LocalDateTime dataCriacao) {
59-
//String utilDate = UtilDate.format(dataCriacao);
54+
public ResponseEntity<DetalheGastosDTO> detalheGastosPorData(@PathVariable String dataCriacao) {
6055
Optional<Gasto> gasto = gastoRepository.findByDataCriacao(dataCriacao);
6156
if (gasto.isPresent()) {
6257
return ResponseEntity.ok(new DetalheGastosDTO(gasto.get()));

testeSantanderWay/src/main/java/br/com/testesantanderway/modelo/Gasto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package br.com.testesantanderway.modelo;
22

3+
import com.fasterxml.jackson.annotation.JsonFormat;
34
import org.apache.solr.client.solrj.beans.Field;
45
import org.springframework.data.annotation.Id;
56
import org.springframework.data.solr.core.mapping.SolrDocument;
@@ -16,6 +17,7 @@ public class Gasto {
1617
@Field
1718
private Double valor;
1819
@Field
20+
@JsonFormat(pattern="dd/MM/yyyy HH:mm:ss"/*2019-07-03T16:24:55.416Z*/)
1921
private LocalDateTime dataCriacao;
2022

2123
public Gasto() {

testeSantanderWay/src/main/java/br/com/testesantanderway/repository/GastoRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.data.domain.Page;
55
import org.springframework.data.domain.Pageable;
66
import org.springframework.data.solr.repository.SolrCrudRepository;
7+
78
import java.util.Optional;
89

910
public interface GastoRepository extends SolrCrudRepository<Gasto, String>{

testeSantanderWay/src/main/java/br/com/testesantanderway/util/UtilDate.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
import java.time.format.DateTimeFormatter;
55

66
public class UtilDate {
7-
private static final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
7+
private static String data;
88

99
public static String format(LocalDateTime dataCriacao) {
10-
return dataCriacao.format(DateTimeFormatter.ofPattern(PATTERN));
10+
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
11+
// LocalDateTime dateTime = LocalDateTime(data, format);
12+
13+
return "";
1114
}
1215
}

0 commit comments

Comments
 (0)