Untitled
unknown
plain_text
2 years ago
727 B
3
Indexable
import java.text.SimpleDateFormat; import java.util.Date; public class StringToDateExample { public static void main(String[] args) { String dateString = "29/03/2023"; SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); try { Date date = dateFormat.parse(dateString); System.out.println("Mes: "+ date.getMonth()); } catch (Exception e) { e.printStackTrace(); } Date fecha = new Date(); System.out.println("Resultado"+fecha); Date fecha2 = new Date(123, 5,3); System.out.println("Resultado 2"+ fecha2); } }
Editor is loading...