This question already has answers here:
Convert unix timestamp to date in java [duplicate]
(3 answers)
Closed 5 years ago.
I receive date and time from openweather api in such format "dt":1489602000", I don't know what that mean. I want to receive something like this "2014-07-23 09:00:00" How can I transform it using SimpleDateFormat
String transformedDate = new SimpleDateFormat("H:mm dd MMM yy").format(new Date(yourTime*1000));
Customize your date format like there
Related
This question already has answers here:
How do I convert the date from one format to another date object in another format without using any deprecated classes?
(10 answers)
Closed 4 years ago.
How do I convert date format from
dd-mm-yyyy
to
YYMMDD
in java?
I think you are seeking the solution like date formatting. You can try to use DateTimeFormatter with your own pattern.
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-MM-dd");
This question already has answers here:
How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?
(16 answers)
Closed 6 years ago.
On my DB i have a date column with this format: '2016-10-05'
How can i obtain the actual date on this format?
I tried with
Date date = new Date();
But the format is not compatible and it doesen't works.
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(stringWithDate);
You have to use SimpleDataFormat which allows you to parse Strings with different formats to Date
This question already has answers here:
java.util.Date format conversion yyyy-mm-dd to mm-dd-yyyy
(8 answers)
Closed 7 years ago.
Has java any function where I have a String with a date in this form : ddMMyy or dd.MM.yy
and I want to convert it in another format like: dd:MM:yy
I would suggest using two SimpleDateFormat objects for this.
Date date = new SimpleDateFormat("ddMMyy").parse( dateString);
String result = new SimpleDateFormat("dd:MM:yy").format( date );
For the format, see the documentation: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
This question already has answers here:
How to format a date String into desirable Date format
(5 answers)
Closed 7 years ago.
I desire to format date string ex.Jul1,201512: 00: 00AM to date in format 'dd/MM/yyyy'.
If any one knows is please share the solution with me
Use a SimpleDateFormat to parse your original string and then another one to format it into the desired format.
This question already has answers here:
Converting ISO 8601-compliant String to java.util.Date
(31 answers)
Closed 8 years ago.
This is what I tried so far but is not working:
This is the format of the date return by the Drive api's json response
2014-04-29T17:58:02.437Z
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
System.out.println(df.parse("2014-04-29T17:58:02.437Z"));
What is the correct way to convert it?
Quick suggestion for:
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.parse("2014-04-29T17:58:02.437Z"));
As you see, Z is simply set by GMT, while you was not parsing 437 milliseconds.
Works for me, just tried it out!