
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Format Date and Time in Java using Join
To format date time with Join, set the date as a string and do not forget to add the delimeter.
For delimeter “/” in the date
String.join("/","11","11","2018");
For delimeter “:” in the date.
String.join(":", "10","20","20");
The following is an example.
Example
public class Demo { public static void main(String[] args) { String d = String.join("/","11","11","2018"); System.out.print("Date: "+d); String t = String.join(":", "10","20","20"); System.out.println("\nTime: "+t); } }
Output
Date: 11/11/2018 Time: 10:20:20
Advertisements