Hi Guys,
In this post we are going to see how to convert ISO time stamp to Java and oracle time stamp using Joda-Time API.
Let's see how to implement Joda-Time API for converting ISO to Java time stamp. We need to include joda-time-1.6.jar or latest version of dependency for working with Joda-Time API.
package in.jodatime;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.joda.time.DateTime;
import org.joda.time.format.*;
public class Jodatime{
public static void main(String[] args) throws ParseException {
DateTimeFormatter parser = ISODateTimeFormat.dateTimeNoMillis();
String jtdate = "2014-11-06T18:18:47+0000"; // ISO Timestamp
DateTime dateTime = parser.parseDateTime(jtdate); // Parse ISO timestamp
String tempDate = dateTime .toString();
System.out.println(tempDate);
//Create SimpleDataFormat For converting from ISO to Java and to Oracle
SimpleDateFormat dateFormat = new SimpleDateFormat("yy-MM-dd'T'h:mm:ss");
Date date = dateFormat .parse(tempDate );
System.out.println(date);
dateFormat = new SimpleDateFormat("dd-MMM-yy h:mm:ss a", Locale.ENGLISH);
String formatDate = dateFormat .format(date);
System.out.println(formatDate );
}
}
Output:
In this post we are going to see how to convert ISO time stamp to Java and oracle time stamp using Joda-Time API.
Joda-Time provides a quality replacement for the Java date and time classes.
Joda-Time is the de facto standard date and time library for Java. From Java SE 8 onwards, users are asked to migrate to java.time (JSR-310).
For more details on Joda-Time API refer http://www.joda.org/joda-time/.Joda-Time is the de facto standard date and time library for Java. From Java SE 8 onwards, users are asked to migrate to java.time (JSR-310).
Let's see how to implement Joda-Time API for converting ISO to Java time stamp. We need to include joda-time-1.6.jar or latest version of dependency for working with Joda-Time API.
package in.jodatime;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.joda.time.DateTime;
import org.joda.time.format.*;
public class Jodatime{
public static void main(String[] args) throws ParseException {
DateTimeFormatter parser = ISODateTimeFormat.dateTimeNoMillis();
String jtdate = "2014-11-06T18:18:47+0000"; // ISO Timestamp
DateTime dateTime = parser.parseDateTime(jtdate); // Parse ISO timestamp
String tempDate = dateTime .toString();
System.out.println(tempDate);
//Create SimpleDataFormat For converting from ISO to Java and to Oracle
SimpleDateFormat dateFormat = new SimpleDateFormat("yy-MM-dd'T'h:mm:ss");
Date date = dateFormat .parse(tempDate );
System.out.println(date);
dateFormat = new SimpleDateFormat("dd-MMM-yy h:mm:ss a", Locale.ENGLISH);
String formatDate = dateFormat .format(date);
System.out.println(formatDate );
}
}
Output:
That's all Folk's..
No comments:
Post a Comment