Samual Sam has Published 2492 Articles

Java Program to parse string date value with default format

Samual Sam

Samual Sam

Updated on 27-Jun-2020 12:43:56

93 Views

For default format, use −DateFormat.getDateInstance(DateFormat.DEFAULT)To parse the string date value, use the parse() methodDate dt = DateFormat.getDateInstance(DateFormat.DEFAULT).parse("Nov 19, 2018");The following is an example −Example Live Demoimport java.text.DateFormat; import java.util.Date; public class Demo {    public static void main(String[] argv) throws Exception {       // parse date       ... Read More

Display Date in E MMM dd yyyy format in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 12:42:43

2K+ Views

Firstly, import the following Java packages −import java.text.SimpleDateFormat; import java.util.Date;Now, create objects −Date dt = new Date(); SimpleDateFormat dateFormat;Displaying date in the format we wantdateFormat = new SimpleDateFormat("E MMM dd yyyy");The following is an example −Example Live Demoimport java.text.SimpleDateFormat; import java.util.Date; public class Demo {    public static void main(String args[]) ... Read More

CSS play-during property

Samual Sam

Samual Sam

Updated on 27-Jun-2020 12:25:48

88 Views

This property specifies a sound to be played as a background while an element's content is spoken. Possible values could be any of the followings −URI − The sound designated by this is played as a background while the element's content is spoken.mix − When present, this keyword means ... Read More

Flip Out X Animation Effect with CSS

Samual Sam

Samual Sam

Updated on 27-Jun-2020 12:16:55

159 Views

To implement Flip Out X Animation effect with CSS, you can try to run the following code −ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;       ... Read More

Java Program to get the day of the week from GregorianCalendar

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:36:40

288 Views

For GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Create an object.GregorianCalendar calendar = new GregorianCalendar();To get the day of the week, use the following field.GregorianCalendar.DAY_OF_WEEKThe following is an example.Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo {    public static void main(String[] a) {       GregorianCalendar calendar = new ... Read More

Java Program to display previous year from GregorianCalendar

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:32:26

114 Views

For GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Create an object.GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();Now, use the following field and add() method with a negative one (-1) to display the previous year.cal.add((GregorianCalendar.YEAR), -1)Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo {    public static void main(String[] a) {       ... Read More

Java Program to parse Time using custom format

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:30:10

153 Views

To get the time format, use the DateFormat class and create a new object.DateFormat dateFormatter = new SimpleDateFormat("hh.mm.ss a");Now, parse the time.dateFormatter.parse("12.55.20 PM");Example Live Demoimport java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main {    public static void main(String[] argv) throws Exception {       DateFormat dateFormatter = new SimpleDateFormat("hh.mm.ss ... Read More

Gregorian Calendar in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:13:00

1K+ Views

GregorianCalendar is a hybrid calendar that supports both the Julian and Gregorian calendar systems with the support of a single discontinuity, which corresponds by default to the Gregorian date when the Gregorian calendar was instituted.The java.util.GregorianCalendar class in Java is a concrete subclass of Calendar and provides the standard calendar ... Read More

Set the Date and Time with Gregorian Calendar in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:07:16

2K+ Views

To work with the GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Create a Date object.Date d = new Date();Now, create an object and set the time using the setTime() method.GregorianCalendar cal = new GregorianCalendar(); cal.setTime(d);The following is an example.Example Live Demoimport java.util.Date; import java.util.GregorianCalendar; public class Demo {    public static void ... Read More

Get the last day of month in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 09:05:14

13K+ Views

The getActualMaximum() method returns the maximum value that the specified calendar field could have, based on the time value of this Calendar.Import the following package to work with Calendar class in Java, import java.util.Calendar;Create a calendar object.Calendar cal = Calendar.getInstance();Use the getActualMaximum() method to get the last day of the ... Read More

Advertisements