Java GrapQL

compile ‘io.leangen.graphql:spqr:0.10.0’
compile group: ‘io.leangen.graphql’, name: ‘graphql-spqr-spring-boot-autoconfigure’, version: ‘0.0.4’

compile ‘com.graphql-java-kickstart:graphql-spring-boot-starter:5.10.0’

// to embed Voyager tool
compile ‘com.graphql-java-kickstart:voyager-spring-boot-starter:5.10.0’

// https://mvnrepository.com/artifact/com.graphql-java-kickstart/playground-spring-boot-starter
compile group: ‘com.graphql-java-kickstart’, name: ‘playground-spring-boot-starter’, version: ‘5.10.0’

code put file attament to s3 aws

import json
import base64
import boto3
import time
import parser
from email.parser import Parser

BUCKET_NAME = ‘s3-trigger-rule’
BUCKET_NAME_STORAGE = ‘attachment-email’
s3 = boto3.client(‘s3’)

def lambda_handler(event, context):
print(‘## EVENT’)
print(event)

file_obj = event[“Records”][0]
print(‘## File Obj’,file_obj)
fileName = event[‘Records’][0][‘s3’][‘object’][‘key’]
print(‘Filename’,fileName)
fileObj = s3.get_object(Bucket=BUCKET_NAME,Key=fileName)
fileContent = fileObj[‘Body’].read().decode(‘utf-8’)
#print(‘fileContent’,fileContent)

parser = Parser()
emailString = parser.parsestr(fileContent)
# print(’emailString’,emailString.get(‘To’).split(“,”))

if emailString.is_multipart():
for part in emailString.walk():
body = part.get_payload()
else:
body = emailString.get_payload()

s3.put_object(Bucket=BUCKET_NAME_STORAGE, Key=fileName, Body=body)

return {
‘statusCode’: 200,
‘body’: fileName
}

Tinh toan tien bac bang BigDecimal

http://chiaseso.vn/tai-sao-nen-su-dung-bigdecimal/

public static void main(String[] args) {
double total = 0.2;
for (int i = 0; i < 100; i++) {
total += 0.2;
}
System.out.println("total = " + total);

BigDecimal ex = new BigDecimal("0.2");
for (int i = 0; i < 100; i ++) {
bdTotal = bdTotal.add(ex);
}
System.out.println("bdTotal : " + bdTotal);
int scale = 4;
double value = 0.11111;
BigDecimal tempBig = new BigDecimal(Double.toString(value));
tempBig = tempBig.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
String strValue = tempBig.stripTrailingZeros().toPlainString();
System.out.println("tempBig = " + strValue);
// floating point calculation
double amount1 = 2.15;
double amount2 = 1.10;
double amount32 = amount1 – amount2;
System.out.println("amount 3" + amount32);
System.out.println("Difference between 2.15 and 1.0 using double is: " + (amount1 – amount2));

// use BigDecimal for financial calculation
BigDecimal amount3 = new BigDecimal("2.15");
BigDecimal amount4 = new BigDecimal("1.10") ;
System.out.println("difference between 2.15 and 1.0 using BigDecimal is: " + (amount3.subtract(amount4)));
}

REsult:
total = 20.19999999999996
bdTotal : 20.2
tempBig = 0.1111
amount 31.0499999999999998
Difference between 2.15 and 1.0 using double is: 1.0499999999999998
difference between 2.15 and 1.0 using BigDecimal is: 1.05

Process finished with exit code 0

https://examples.javacodegeeks.com/core-java/math/bigdecimal-example/

Website Powered by WordPress.com.

Up ↑