Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sample;
- import static java.lang.System.err;
- import static java.lang.System.out;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- public class TestDate1 {
- public static void main(String[] args) {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd aa hh:mm");
- String date1 = "2020-12-4 AM 10:4";
- java.util.Date date = null;
- try {
- date = simpleDateFormat.parse(date1);
- } catch (ParseException ex) {
- ex.printStackTrace();
- }
- if (date != null) {
- out.println(date.toLocaleString());
- } else {
- err.println("parse date error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment