Wie kann ich in Java das Datum in den Dateinamen einbinden?

3 Antworten

Vom Fragesteller als hilfreich ausgezeichnet

Du musst angeben in welchem Format du das Datum haben willst

Date date = Calendar.getInstance().getTime(); 
DateFormat dateFormat =  new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");  
String strDate = dateFormat.format(date);  

https://www.javatpoint.com/java-date-to-string

Woher ich das weiß:Studium / Ausbildung – Fachinformatiker
Vampir21 
Fragesteller
 17.03.2020, 08:50

Danke jetzt funktioniert es

0

Du musst bestimmte zeichen in Strings in Java escapen:

String workFiles= new String ("My work files are in D:\\Work Projects\\java");
System.out.println(workFiles);
Let's see what we get:
Console output:
My work files are in D:\Work Projects\java
Super! The compiler immediately determines that the
\
are ordinary characters that should be displayed along with the rest.

https://codegym.cc/groups/posts/escaping-characters-java

LG

Woher ich das weiß:Studium / Ausbildung – Gelernter Fachinformatiker, Freiberufl. Softwareentwickler