-->
Skip to main content

Posts

Showing posts from June, 2021

Convert Java Instant to Date [2021]

Convert Java Instant to Date [2021] In this tutorial, We will Convert Java Instant to Date using Date.from(Instant instant) method. Java Instant to Date Example This example shows how to convert Java Instant to Date using Date.from(Instant instant) method. import java.time.Instant; import java.util.Date; public class JavaInstantNowToDate { public static void main(String[] args) { Instant instant = Instant.now(); System.out.println("Instant : " + instant); // Java Instant now to Date Date date = Date.from(instant); System.out.println("Java Instant to Date : " + date); } } Output: Instant : 2021-06-29T16:36:19.769Z Java Instant to Date : Tue Jun 29 16:36:19 IST 2021 Conclusion In this tutorial, we have covered how to convert Java Instant to Date using the Date class static method Date.from(Instant instant). Thanks for reading this tutorial so far. If you like this tutorial then please share it with your friends and colleagues. If you h

Convert calendar to date in java [2021]

Convert calendar to date in java [2021] In this tutorial, we will cover how to convert calendar to date in Java, Calendar class has static method Calendar.getInstance().getTime() which will give date class instance. Calendar to date in Java import java.util.Calendar; import java.util.Date; public class CalendarToDate { public static void main(String[] args) { //Creating calendar instance Calendar cal = Calendar.getInstance(); //Converting calendar to date Date date = cal.getTime(); //Output : Tue Jun 15 20:22:07 IST 2021 System.out.println(date); } } Output: Tue Jun 15 20:22:07 IST 2021 Conclusion In this tutorial, We have covered how to convert Calendar instance to date instance. Thanks for reading this tutorial so far. If you like this tutorial then please share it with your friends and colleagues. If you have any questions, doubts, suggestions, or feedback then please drop a comment and I'll try to answer your question. So what do you think about this

Solution : Improper Output Neutralization For Logs (CWE ID 117)

Solution: Improper Output Neutralization For Logs (CWE ID 117) Today we will give the solution for Improper Output Neutralization For Logs (CWE ID 117) which is one of the things that Veracode shows to fix the CRLF Injection. Why it Occured as Per Veracode documentation  A function call could result in a log forging attack. Writing untrusted data into a log file allows an attacker to forge log entries or inject malicious content into log files. Corrupted log files can be used to cover an attacker's tracks or as a delivery mechanism for an attack on a log viewing or processing utility. For example, if a web administrator uses a browser-based utility to review logs, a cross-site scripting attack might be possible. Thus if we don't fix this it will allow attackers to inject malicious content into our logs. Recommadation by documentation Avoid directly embedding user input in log files when possible. Sanitize untrusted data used to construct log entries by using a safe logging mec