Daniol Thomas has Published 209 Articles

How to update the contents of a ResultSet using a JDBC program?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

87 Views

To update the contents of the ResultSet you need to create a statement by passing the ResultSet type updatable, as://Creating a Statement object Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Just like getXXX() and setXXX() methods ResultSet interface also provides methods to update the contents of a row in a result set updateXXX().These ... Read More

Java Program to check for the supported attribute via java.nio.file.FileStore

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

64 Views

Following is our file:Path p = Paths.get("E:/input.txt"); FileStore file = Files.getFileStore(p);Now, check for the supported attributes one by one:FileAttributeView = file.supportsFileAttributeView(FileAttributeView.class) PosixFileAttributeView = file.supportsFileAttributeView(PosixFileAttributeView.class) BasicFileAttributeView = file.supportsFileAttributeView(BasicFileAttributeView.class)Exampleimport java.nio.file.FileStore; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileAttributeView; import java.nio.file.attribute.FileOwnerAttributeView; import java.nio.file.attribute.PosixFileAttributeView; public class Demo {    public static void ... Read More

Java Program to format date as Apr 19, 2019, 1:27 PM

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

152 Views

To format and display datetime, you need to use DateTimeFormatter. The format style is MEDIUM and SHORT:DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT);Display the formatted date:formatter.format(LocalDateTime.now()Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; public class Demo {    public static void main(String[] args) {       DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT); ... Read More

Java Program to format date as Apr 14 2019 01:35 PM IST

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

72 Views

To format and display datetime, you need to use DateTimeFormatter and use the pattern as:DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z");Above, the z is the timezone:MMM dd yyyy hh:mm a zNow, use the following for zone:ZonedDateTime dateTime = ZonedDateTime.now();Exampleimport java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Demo {    public ... Read More

How to format Java LocalDateTime as ISO_DATE_TIME format

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

3K+ Views

At first, set the date:LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);Now, format the datetime as ISO_DATE_TIME format:String str = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);Exampleimport java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);     ... Read More

Java Program to format LocalDateTime as ISO_WEEK_DATE format

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

125 Views

At first, set the date:LocalDateTime dateTime = LocalDateTime.of(2019, Month.SEPTEMBER, 9, 10, 20);Now, format the datetime as ISO_WEEK_DATE format:String str = dateTime.format(DateTimeFormatter.ISO_WEEK_DATE);Exampleimport java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDateTime dateTime = LocalDateTime.of(2019, Month.SEPTEMBER, 9, 10, 20);     ... Read More

IntStream mapToObj() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

2K+ Views

The mapToObj() method in the IntStream class returns an object-valued Stream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows. StreammapToObj(IntFunction

IntStream mapToLong() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

523 Views

The mapToLong() function in IntStream class returns a LongStream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows.LongStream mapToLong(IntToLongFunction mapper)Here, the parameter mapper is a stateless function to apply to each element.Create an IntStream with some elements in the Stream.IntStream ... Read More

Collectors collectingAndThen() method in Java 8

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

763 Views

The collectingAndThen() method in Java Collectors class acclimates a Collector to perform an additional finishing transformation. It returns collector which performs the action of the downstream collector, followed by an additional ending step.The syntax is as follows.static Collector collectingAndThen(Collector downstream, Function finisher)Here, the parameter, T − Type of the ... Read More

Collectors partitioningBy() method in Java 8

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

1K+ Views

The partioningBy() method returns a Collector that partitions the input elements according to a Predicate, and organizes them into a Map.The syntax is as follows.static Collector partitioningBy(Predicate

Advertisements