Merge branch 'master' into BAEL-10839

This commit is contained in:
Loredana Crusoveanu 2018-12-25 15:25:31 +02:00 committed by GitHub
commit ed05ee188b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 269 additions and 51 deletions

View File

@ -31,3 +31,6 @@
- [Brief Introduction to Java Thread.yield()](https://www.baeldung.com/java-thread-yield) - [Brief Introduction to Java Thread.yield()](https://www.baeldung.com/java-thread-yield)
- [Print Even and Odd Numbers Using 2 Threads](https://www.baeldung.com/java-even-odd-numbers-with-2-threads) - [Print Even and Odd Numbers Using 2 Threads](https://www.baeldung.com/java-even-odd-numbers-with-2-threads)
- [Java CyclicBarrier vs CountDownLatch](https://www.baeldung.com/java-cyclicbarrier-countdownlatch) - [Java CyclicBarrier vs CountDownLatch](https://www.baeldung.com/java-cyclicbarrier-countdownlatch)
- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
- [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random)
- [The Thread.join() Method in Java](http://www.baeldung.com/java-thread-join)

View File

@ -47,6 +47,16 @@
<version>${avaitility.version}</version> <version>${avaitility.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-generator-annprocess.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -69,6 +79,8 @@
<!-- testing --> <!-- testing -->
<assertj.version>3.6.1</assertj.version> <assertj.version>3.6.1</assertj.version>
<avaitility.version>1.7.0</avaitility.version> <avaitility.version>1.7.0</avaitility.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
</properties> </properties>
</project> </project>

25
core-java-lang-syntax/.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
*.class
0.*
#folders#
/target
/neoDb*
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
.resourceCache
# Packaged files #
*.jar
*.war
*.ear
# Files generated by integration tests
backup-pom.xml
/bin/
/temp
#IntelliJ specific
.idea/
*.iml

View File

@ -0,0 +1,19 @@
=========
## Core Java Lang Syntax Cookbooks and Examples
### Relevant Articles:
- [Introduction to Java Generics](http://www.baeldung.com/java-generics)
- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization)
- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator)
- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break)
- [A Guide to Java Initialization](http://www.baeldung.com/java-initialization)
- [A Guide to Java Loops](http://www.baeldung.com/java-loops)
- [Varargs in Java](http://www.baeldung.com/java-varargs)
- [A Guide to Java Enums](http://www.baeldung.com/a-guide-to-java-enums)
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system)
- [Java Switch Statement](https://www.baeldung.com/java-switch)
- [The Modulo Operator in Java](https://www.baeldung.com/modulo-java)
- [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator)

View File

@ -0,0 +1,53 @@
<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.baeldung</groupId>
<artifactId>core-java-lang-syntax</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>core-java-lang-syntax</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-java</relativePath>
</parent>
<dependencies>
<!-- logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<!-- test scoped -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>core-java-lang-syntax</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<!-- testing -->
<assertj-core.version>3.10.0</assertj-core.version>
</properties>
</project>

View File

@ -0,0 +1,53 @@
package com.baeldung.initializationguide;
import java.io.Serializable;
public class User implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
static String forum;
private String name;
private int id;
{
id = 0;
System.out.println("Instance Initializer");
}
static {
forum = "Java";
System.out.println("Static Initializer");
}
public User(String name, int id) {
super();
this.name = name;
this.id = id;
}
public User() {
System.out.println("Constructor");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
protected Object clone() throws CloneNotSupportedException {
return this;
}
}

View File

@ -0,0 +1,37 @@
package com.baeldung.initializationguide;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import java.lang.reflect.InvocationTargetException;
public class UserUnitTest {
@Test
public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
User user = new User("Alice", 1);
assertThat(user).isNotNull();
}
@Test
public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
User user = User.class.getConstructor(String.class, int.class)
.newInstance("Alice", 2);
assertThat(user).isNotNull();
}
@Test
public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException {
User user = new User("Alice", 3);
User clonedUser = (User) user.clone();
assertThat(clonedUser).isEqualTo(user);
}
@Test
public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() {
User user = new User();
assertThat(user.getName()).isNull();
assertThat(user.getId() == 0);
}
}

View File

@ -4,9 +4,8 @@
### Relevant Articles: ### Relevant Articles:
- [Guide to Java Reflection](http://www.baeldung.com/java-reflection) - [Guide to Java Reflection](http://www.baeldung.com/java-reflection)
- [Introduction to Java Generics](http://www.baeldung.com/java-generics) - [Generate equals() and hashCode() with Eclipse](http://www.baeldung.com/java-eclipse-equals-and-hashcode)
- [Chained Exceptions in Java](http://www.baeldung.com/java-chained-exceptions) - [Chained Exceptions in Java](http://www.baeldung.com/java-chained-exceptions)
- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
- [Call Methods at Runtime Using Java Reflection](http://www.baeldung.com/java-method-reflection) - [Call Methods at Runtime Using Java Reflection](http://www.baeldung.com/java-method-reflection)
- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration) - [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration)
- [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params) - [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params)
@ -16,8 +15,6 @@
- [Quick Example - Comparator vs Comparable in Java](http://www.baeldung.com/java-comparator-comparable) - [Quick Example - Comparator vs Comparable in Java](http://www.baeldung.com/java-comparator-comparable)
- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break) - [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break)
- [Nested Classes in Java](http://www.baeldung.com/java-nested-classes) - [Nested Classes in Java](http://www.baeldung.com/java-nested-classes)
- [A Guide to Java Loops](http://www.baeldung.com/java-loops)
- [Varargs in Java](http://www.baeldung.com/java-varargs)
- [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces) - [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces)
- [Recursion In Java](http://www.baeldung.com/java-recursion) - [Recursion In Java](http://www.baeldung.com/java-recursion)
- [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize) - [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize)
@ -33,9 +30,6 @@
- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) - [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding)
- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws) - [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws)
- [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic) - [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic)
- [Java Switch Statement](https://www.baeldung.com/java-switch)
- [The Modulo Operator in Java](https://www.baeldung.com/modulo-java)
- [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator)
- [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts) - [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts)
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws) - [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
- [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name) - [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name)

View File

@ -5,3 +5,9 @@
### Relevant Articles ### Relevant Articles
- [Connecting Through Proxy Servers in Core Java](https://www.baeldung.com/java-connect-via-proxy-server) - [Connecting Through Proxy Servers in Core Java](https://www.baeldung.com/java-connect-via-proxy-server)
- [Broadcasting and Multicasting in Java](http://www.baeldung.com/java-broadcast-multicast)
- [A Guide To UDP In Java](http://www.baeldung.com/udp-in-java)
- [Sending Emails with Java](http://www.baeldung.com/java-email)
- [A Guide To HTTP Cookies In Java](http://www.baeldung.com/cookies-java)
- [A Guide to the Java URL](http://www.baeldung.com/java-url)
- [Working with Network Interfaces in Java](http://www.baeldung.com/java-network-interfaces)

View File

@ -13,7 +13,25 @@
<relativePath>../parent-java</relativePath> <relativePath>../parent-java</relativePath>
</parent> </parent>
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>
<build> <build>
<finalName>core-java-networking</finalName> <finalName>core-java-networking</finalName>
</build> </build>
<properties>
<javax.mail.version>1.5.0-b01</javax.mail.version>
<commons-io.version>2.5</commons-io.version>
</properties>
</project> </project>

View File

@ -1,4 +1,4 @@
package com.baeldung.javanetworking.uriurl; package com.baeldung.networking.uriurl;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.baeldung.javanetworking.uriurl; package com.baeldung.networking.uriurl;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.transaction" level="WARN" />
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,4 +1,4 @@
package com.baeldung.java.networking.interfaces; package com.baeldung.networking.interfaces;
import org.junit.Test; import org.junit.Test;

View File

@ -1,4 +1,4 @@
package com.baeldung.javanetworking.uriurl.test; package com.baeldung.networking.uriurl;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -20,7 +20,7 @@ import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.baeldung.javanetworking.uriurl.URLDemo; import com.baeldung.networking.uriurl.URLDemo;
@FixMethodOrder @FixMethodOrder
public class URIDemoLiveTest { public class URIDemoLiveTest {

View File

@ -1,4 +1,4 @@
package com.baeldung.javanetworking.uriurl; package com.baeldung.networking.uriurl;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;

View File

@ -1,4 +1,4 @@
package com.baeldung.javanetworking.uriurl.test; package com.baeldung.networking.uriurl;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -18,7 +18,7 @@ import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.baeldung.javanetworking.uriurl.URLDemo; import com.baeldung.networking.uriurl.URLDemo;
@FixMethodOrder @FixMethodOrder
public class URLDemoLiveTest { public class URLDemoLiveTest {

View File

@ -1,4 +1,4 @@
package com.baeldung.java.networking.url; package com.baeldung.networking.url;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

View File

@ -7,7 +7,6 @@
- [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java) - [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java)
- [MD5 Hashing in Java](http://www.baeldung.com/java-md5) - [MD5 Hashing in Java](http://www.baeldung.com/java-md5)
- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) - [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets)
- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
- [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java) - [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java)
- [A Guide To Java Regular Expressions API](http://www.baeldung.com/regular-expressions-java) - [A Guide To Java Regular Expressions API](http://www.baeldung.com/regular-expressions-java)
- [Getting Started with Java Properties](http://www.baeldung.com/java-properties) - [Getting Started with Java Properties](http://www.baeldung.com/java-properties)
@ -27,13 +26,11 @@
- [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Guide to UUID in Java](http://www.baeldung.com/java-uuid)
- [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char) - [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char)
- [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri)
- [Broadcasting and Multicasting in Java](http://www.baeldung.com/java-broadcast-multicast)
- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) - [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded)
- [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin)
- [Quick Guide to Java Stack](http://www.baeldung.com/java-stack) - [Quick Guide to Java Stack](http://www.baeldung.com/java-stack)
- [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) - [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter)
- [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class) - [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class)
- [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random)
- [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac)
- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) - [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator)
- [Introduction to Javadoc](http://www.baeldung.com/javadoc) - [Introduction to Javadoc](http://www.baeldung.com/javadoc)
@ -42,31 +39,20 @@
- [How to Detect the OS Using Java](http://www.baeldung.com/java-detect-os) - [How to Detect the OS Using Java](http://www.baeldung.com/java-detect-os)
- [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java) - [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java)
- [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) - [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid)
- [A Guide To UDP In Java](http://www.baeldung.com/udp-in-java)
- [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle)
- [Class Loaders in Java](http://www.baeldung.com/java-classloaders) - [Class Loaders in Java](http://www.baeldung.com/java-classloaders)
- [Sending Emails with Java](http://www.baeldung.com/java-email)
- [Introduction to SSL in Java](http://www.baeldung.com/java-ssl) - [Introduction to SSL in Java](http://www.baeldung.com/java-ssl)
- [Java KeyStore API](http://www.baeldung.com/java-keystore) - [Java KeyStore API](http://www.baeldung.com/java-keystore)
- [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking) - [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking)
- [Guide to Java Clock Class](http://www.baeldung.com/java-clock) - [Guide to Java Clock Class](http://www.baeldung.com/java-clock)
- [Introduction to Creational Design Patterns](http://www.baeldung.com/creational-design-patterns)
- [Proxy, Decorator, Adapter and Bridge Patterns](http://www.baeldung.com/java-structural-design-patterns)
- [Singletons in Java](http://www.baeldung.com/java-singleton)
- [Flyweight Pattern in Java](http://www.baeldung.com/java-flyweight)
- [The Observer Pattern in Java](http://www.baeldung.com/java-observer-pattern)
- [Service Locator Pattern](http://www.baeldung.com/java-service-locator-pattern)
- [The Thread.join() Method in Java](http://www.baeldung.com/java-thread-join)
- [Importance of Main Manifest Attribute in a Self-Executing JAR](http://www.baeldung.com/java-jar-executable-manifest-main-class) - [Importance of Main Manifest Attribute in a Self-Executing JAR](http://www.baeldung.com/java-jar-executable-manifest-main-class)
- [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension) - [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension)
- [Console I/O in Java](http://www.baeldung.com/java-console-input-output)
- [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) - [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler)
- [Encrypting and Decrypting Files in Java](http://www.baeldung.com/java-cipher-input-output-stream) - [Encrypting and Decrypting Files in Java](http://www.baeldung.com/java-cipher-input-output-stream)
- [How to Get the Size of an Object in Java](http://www.baeldung.com/java-size-of-object) - [How to Get the Size of an Object in Java](http://www.baeldung.com/java-size-of-object)
- [Guide to Java Instrumentation](http://www.baeldung.com/java-instrumentation) - [Guide to Java Instrumentation](http://www.baeldung.com/java-instrumentation)
- [Getting a Files Mime Type in Java](http://www.baeldung.com/java-file-mime-type) - [Getting a Files Mime Type in Java](http://www.baeldung.com/java-file-mime-type)
- [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions) - [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions)
- [Java Constructors vs Static Factory Methods](https://www.baeldung.com/java-constructors-vs-static-factory-methods)
- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception) - [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception)
- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string)
- [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) - [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root)
@ -85,3 +71,4 @@
- [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area) - [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area)
- [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math) - [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math)
- [Graphs in Java](https://www.baeldung.com/java-graphs) - [Graphs in Java](https://www.baeldung.com/java-graphs)
- [Console I/O in Java](http://www.baeldung.com/java-console-input-output)

View File

@ -131,11 +131,6 @@
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>${h2database.version}</version> <version>${h2database.version}</version>
</dependency> </dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<!-- Mime Type Resolution Libraries --> <!-- Mime Type Resolution Libraries -->
<dependency> <dependency>
<groupId>org.apache.tika</groupId> <groupId>org.apache.tika</groupId>
@ -514,7 +509,6 @@
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version> <jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version> <maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
<javax.mail.version>1.5.0-b01</javax.mail.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version> <onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version>
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version> <maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>

View File

@ -1,5 +0,0 @@
### Relevant Articles:
- [A Guide To UDP In Java](http://www.baeldung.com/udp-in-java)
- [A Guide To HTTP Cookies In Java](http://www.baeldung.com/cookies-java)
- [A Guide to the Java URL](http://www.baeldung.com/java-url)
- [Working with Network Interfaces in Java](http://www.baeldung.com/java-network-interfaces)

View File

@ -11,7 +11,6 @@ import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.junit.Test; import org.junit.Test;
@ -24,8 +23,9 @@ import com.baeldung.jackson.date.EventWithSerializer;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import com.fasterxml.jackson.datatype.joda.JodaModule; import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.datatype.jsr310.JSR310Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
public class JacksonDateUnitTest { public class JacksonDateUnitTest {
@ -54,10 +54,12 @@ public class JacksonDateUnitTest {
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setDateFormat(new ISO8601DateFormat());
// StdDateFormat is ISO8601 since jackson 2.9
mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
final String result = mapper.writeValueAsString(event); final String result = mapper.writeValueAsString(event);
assertThat(result, containsString("1970-01-01T02:30:00Z")); assertThat(result, containsString("1970-01-01T02:30:00.000+00:00"));
} }
@Test @Test
@ -152,7 +154,7 @@ public class JacksonDateUnitTest {
final LocalDateTime date = LocalDateTime.of(2014, 12, 20, 2, 30); final LocalDateTime date = LocalDateTime.of(2014, 12, 20, 2, 30);
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR310Module()); mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
final String result = mapper.writeValueAsString(date); final String result = mapper.writeValueAsString(date);

View File

@ -1,8 +1,3 @@
### Relevant Articles: ### Relevant Articles:
- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern) - [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java) - [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
- [Implementing the Template Method Pattern in Java](http://www.baeldung.com/java-template-method-pattern)
- [Chain of Responsibility Design Pattern in Java](http://www.baeldung.com/chain-of-responsibility-pattern)
- [The Command Pattern in Java](http://www.baeldung.com/java-command-pattern)
- [The DAO Pattern in Java](http://www.baeldung.com/java-dao-pattern)

View File

@ -14,3 +14,7 @@
- [State Design Pattern in Java](https://www.baeldung.com/java-state-design-pattern) - [State Design Pattern in Java](https://www.baeldung.com/java-state-design-pattern)
- [The Decorator Pattern in Java](https://www.baeldung.com/java-decorator-pattern) - [The Decorator Pattern in Java](https://www.baeldung.com/java-decorator-pattern)
- [Abstract Factory Pattern in Java](https://www.baeldung.com/java-abstract-factory-pattern) - [Abstract Factory Pattern in Java](https://www.baeldung.com/java-abstract-factory-pattern)
- [Implementing the Template Method Pattern in Java](http://www.baeldung.com/java-template-method-pattern)
- [Chain of Responsibility Design Pattern in Java](http://www.baeldung.com/chain-of-responsibility-pattern)
- [The Command Pattern in Java](http://www.baeldung.com/java-command-pattern)
- [Java Constructors vs Static Factory Methods](https://www.baeldung.com/java-constructors-vs-static-factory-methods)

View File

@ -381,6 +381,7 @@
<module>core-java-collections</module> <module>core-java-collections</module>
<module>core-java-concurrency-collections</module> <module>core-java-concurrency-collections</module>
<module>core-java-io</module> <module>core-java-io</module>
<module>core-java-lang-syntax</module>
<module>core-java-lang</module> <module>core-java-lang</module>
<module>core-java-lang-oop</module> <module>core-java-lang-oop</module>
<module>core-java-networking</module> <module>core-java-networking</module>
@ -1089,6 +1090,7 @@
<module>core-java-collections</module> <module>core-java-collections</module>
<module>core-java-concurrency-collections</module> <module>core-java-concurrency-collections</module>
<module>core-java-io</module> <module>core-java-io</module>
<module>core-java-lang-syntax</module>
<module>core-java-lang</module> <module>core-java-lang</module>
<module>core-java-lang-oop</module> <module>core-java-lang-oop</module>
<module>core-java-networking</module> <module>core-java-networking</module>