I have a combo box with list of the current date with a different format. When the user selected the format, the current date with the selected format will be display. I need to save the selected pattern of the date in a file. I look everywhere and I can't find a specific answer for my problem. Is there a way to get the specific pattern of a date in java?
From the docs :
public String toPattern()
Returns a pattern string describing this date format.
When user select date-format bring that format here and pass , like "dd-MM-yyyy HH:mm" and display like that:
SimpleDateFormat formatter = new SimpleDateFormat(<Pass_here_your_date_format);
Date date = new Date();
try {
date = formatter.parse(strDate);
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
System.out.println(date);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.