Sunday, June 1, 2014

Java SE 8 :: Date and Time

Java SE 8 Features - 2
Date and Time in Java SE 8


 
 

As you can find from above, Date and Time in Java 8 replaces shockingly Util.Date, Calendar, TimeZone DateFormat,
All now are replaced with the following range of types:

 
 

To make it more clear let take the following example to get to know more about the syntax of the date and time in Java SE 8.

Let’s say the date is 1st June 2014 15:30.
LocalDate localDate = LocalDate.of(2014,Month.June,1);
LocalTime localTime = LocalTime.of(15, 30);
LocalDateTime localDateTime = LocalDateTime.of(2014,Month.June,1,15,30);

Sample of new Date methods:
-          To find if this year is leap or not : Date.isLeapYear();
-          localDate.minusMonth(3).plusDays(10); on previous example will generate 10/3/2014.
-          localTime.now(),localDate.now(),localDateTime.now(); to get current Date.
-          And many others: D.

Local Date Adjuster:
You may adjust the date with some constant values as follows
localDate = localDate.with(TemporalAdjuster.LastDateOfMonth);
Will generate 30/6/2014.

Happy News for developers deals with Saudi companies:
Chronology:
Which is other types of Calendar, and now Hijri calendar is supported.

Wednesday, May 28, 2014

JAVA 8 :: Lambda Expressions

Lambda Expressions

"Lambda expressions are a new and important feature included in Java SE 8. They provide a clear and concise way to represent one method interface using an expression." as defined by oracle

And how it will represent it?!

To make it clear lets go through the following example:

We Are looping over array list of users searching for users with > 30 ages.

Old Java Way:
  private static void oldJavaWay() {
    List<User> olderUsers = new ArrayList<User>();

    for (User u : users) {
      if (u.age > 30) {
        olderUsers.add(u);
      }
    }

    printListNewWay("Old way older users", olderUsers);
  }
New Java Way Using Lambda:
private static void newJavaWay() {
    List<User> olderUsers = users.stream().filter(u -> u.age > 30).collect(Collectors.toList());
    printListNewWay("New way older users", olderUsers);
  }
What happened up there!!!!
Using lambda 6 line of code become only 1 :)
streams the user array list, filter the list and return it as new array list :D.
Lambda expressions and I will concentrate on the filter it goes like that 
filter((What???) user -> (How???) user.age > 30);

Monday, December 16, 2013

Web Services :: Bottom Up vs Top Down Web Services

Bottom Up vs Top Down Web Services

Top-down means you start with a WSDL and then create all the necessary scaffolding in Java all the way down.
Bottom-up means you start with a Java method, and generate the WSDL from it.

Tuesday, July 23, 2013

Gen :: Solve When Virus Hit My Flash and Hide My Files

What to do When Virus Hit My Flash and Hide My Files?

Try the following steps:
1. Go to Start > Run > type cmd
2. Dos will open type cd\
3. Now type the drive letter in which you want to Unhide the files lets suppose in my case its E: this will open the E: drive
4. If you want to see all hidden files and folders   type E:\>dir/ah
5. Now type attrib *. -h -s /s /d
6. Now close cmd using exit command


then move all the files you need on the flash , format it to insure all viruses are cleaned.

Sunday, June 30, 2013

Java :: How To Override toString

How To Override toString
@Override public String toString()
{
return this.get(Field you want to return); // e.g: getName();
}

Why to use this kind override?
Sometimes we need to add for example a collection to a combo box so instead of looping
 over the object list you override the toString in that object to return one of the object variables

Sunday, June 9, 2013

Java :: HotSpot

Java HotSpot

The Java HotSpot Virtual Machine is a core component of the Java SE platform. It implements the Java Virtual Machine Specification, and is delivered as a shared library in the Java Runtime Environment. As the Java bytecode execution engine, it provides Java runtime facilities, such as thread and object synchronization, on a variety of operating systems and architectures. It includes dynamic compilers that adaptively compile Java bytecodes into optimized machine instructions and efficiently manages the Java heap using garbage collectors, optimized for both low pause time and throughput. It provides data and information to profiling, monitoring and debugging tools and applications.
HotSpot is an "ergonomic" JVM. Based upon the platform configuration, it will select a compiler, Java heap configuration, and garbage collector that produce good to excellent performance for most applications. Under special circumstances, however, specific tuning may be required to get the best possible performance. The resources collected here will help the reader understand and tune the Java HotSpot Virtual Machine.

The Java HotSpot Performance Engine Architecture