Instantly share code, notes, and snippets.

View OrderTransaction.java
@Entity
@Table(name = "order_transaction")
@Data
public class OrderTransaction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long orderId;
private String OrderProduct;
private LocalDate orderDate;
View hibernate-java8.xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>${hibernate.version}</version>
</dependency>
View order_transaction.sql
CREATE TABLE `order_transaction` (
`orderId` bigint(20) NOT NULL AUTO_INCREMENT,
`OrderProduct` varchar(255) DEFAULT NULL,
`orderCreated` timestamp NULL DEFAULT NULL,
`orderDate` date DEFAULT NULL,
`orderTime` time DEFAULT NULL,
PRIMARY KEY (`orderId`)
)
View pom.xml
.......
<properties>
<hibernate.version>5.0.0.Final</hibernate.version>
<mysql.version>5.1.36</mysql.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
View Main.java
public static void main(String[] args) {
EntityManager em =PersistenceManager.INSTANCE.getEntityManager();
em.getTransaction().begin();
for (int i = 0; i < 10; i++) {
OrderTransaction order=new OrderTransaction();
order.setOrderProduct("Computer No "+i);
//Date With LocalDate
order.setOrderDate(LocalDate.now());
//Time With LocalTime
order.setOrderTime(LocalTime.now());
View Kembalian.java
public class Kembalian{
public static void pecahUang(Long nilai){
Long _nilai=nilai;
/*Nilai Pecahan Indonesia*/
Long _100rb=100000L;
Long _50rb =50000L;
Long _20rb =20000L;
Long _10rb = 10000L;
View Pembulatan.java
import java.math.RoundingMode;
import java.math.BigDecimal;
public class Pembulatan
{
public static int pembulatan1000( int nilai ){
BigDecimal _value = new BigDecimal( (double)nilai/1000);
_value= _value.setScale(0,RoundingMode.UP);
return _value.intValue()*1000;
}
public static void main(String []args){
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mongodb</groupId>
<artifactId>spark-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>M101J</name>
View Implementasi Mail Util
@Override
public Map<String, Object> sendNotif(List<RequestEmailNotifHelper>requests) {
try {
//TODO: open remark after ready to implemented
HashMap<String, Object> param = new HashMap<>() ;
param.put(IEmailNotifConstans.IMailParamJson.TEMPLATE_ID,4568);
View Implementasi Mail Util
@Override
public Map<String, Object> sendNotif(List<RequestEmailNotifHelper>requests) {
try {
//TODO: open remark after ready to implemented
HashMap<String, Object> param = new HashMap<>() ;
param.put(IEmailNotifConstans.IMailParamJson.TEMPLATE_ID,4568);