Formatting date string to desired date in Java [duplicate] - java

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.

Related

Convert date format from dd-mm-yyyy to YYMMDD [duplicate]

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");

print date in format YYYY-MM-DDThh:mm:ssTZD without using JODA time or Apache fast date format [duplicate]

This question already has answers here:
How to format date string in java? [duplicate]
(3 answers)
Closed 5 years ago.
Can anyone help me to print date in the format below
2016-11-22T14:52:17+05:30
without using JODA Time and apache fast date format.
Use SimpleDateFormat:
System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date()));
or in Java8 DateTimeFormatter:
System.out.println(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ").format(ZonedDateTime.now()));

How to parse openweather data with simpledate format [duplicate]

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

Java 7: Actual Date format yyyy-mm-dd [duplicate]

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

Java - Date Format converter? [duplicate]

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

Categories

Resources