Real unit test (isolation, no children render)
Calls:
- constructor
- render
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Title</title> | |
<link href="stylesheets/main.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<header> | |
<hgroup> |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation | |
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration | |
@SpringBootApplication | |
public class FooApplication { | |
public static void main(String[] args) { | |
// Bootstrap the application | |
SpringApplication.run(FooApplication.class, args); | |
} | |
} |
public class GetDayFromDate { | |
public static void main(String[] args) { | |
Date now = new Date(); | |
SimpleDateFormat simpleDateformat = new SimpleDateFormat("E"); // the day of the week abbreviated | |
System.out.println(simpleDateformat.format(now)); | |
simpleDateformat = new SimpleDateFormat("EEEE"); // the day of the week spelled out completely |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.TimeZone; | |
/** | |
* | |
* Java program to display a date in different timezone in Java. Internally Java | |
* stores date as millisecond passed since 01-01-1970 00:00 GMT, which can be |
import java.time.LocalTime; | |
import java.time.ZoneId; | |
import java.time.ZoneOffset; | |
import java.time.ZonedDateTime; | |
public class HelloWorld{ | |
public static void main(String []args){ | |
System.out.println("Hello World"); | |
LocalTime time = LocalTime.parse("10:00:00"); // 10 AM |
public static Date localToGMT() { | |
Date date = new Date(); | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); | |
sdf.setTimeZone(TimeZone.getTimeZone("UTC")); | |
Date gmt = new Date(sdf.format(date)); | |
return gmt; | |
} | |
public static Date gmttoLocalDate(Date date) { |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.time.LocalTime; | |
import java.time.ZoneId; | |
import java.time.ZoneOffset; | |
import java.time.ZonedDateTime; | |
import java.util.Calendar; | |
import java.util.Date; |