I need to get the Date of the current time with the following format "yyyy-MM-dd'T'HH:mm:ss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
I know how to format a Date using SimpleDateFormat. At the end I get a String. But I need to get the formatted Date, not String, and as far as I know, I cannot convert back a String to a Date, can I?
If I just return the Date, it is a Date but it is not properly formatted:
Timestamp ts = new Timestamp(new Date().getTime());
EDIT:
Unfortunately I need to get the outcome as a Date, not a String, so I cannot use sdf.format(New Date().getTime()) as this returns a String.
Also, the Date I need to return is the Date of the current time, not from a static String. I hope that clarifies
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…