Refactor the stream applications

Thanks to Soby Chacko for the suggestions
This commit is contained in:
Ilayaperumal Gopinathan
2020-05-02 07:17:55 +05:30
parent 6324d6e78a
commit dc20f90f03
3 changed files with 30 additions and 45 deletions

View File

@@ -7,26 +7,20 @@ import java.util.function.Supplier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
public class TimeSourceApplication {
@Bean
public Supplier<String> timeSupplier() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return () -> {
return sdf.format(new Date());
};
}
public static void main(String[] args) {
SpringApplication.run(TimeSourceApplication.class, args);
}
@Configuration
public class TimeSupplierConfiguration {
public TimeSupplierConfiguration() {
}
@Bean
public Supplier<String> timeSupplier() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return () -> {
return sdf.format(new Date());
};
}
}
}