2016-08-30

رسمياً .. برشلونة يعلن التوقيع مع باكو ألكاسير



رسمياً .. برشلونة يعلن التوقيع مع باكو ألكاسير

أعلن نادي برشلونة الإسباني رسمياً عبر موقعه الإلكتروني على الانترنت قبل قليل عن التوقيع مع مهاجم نادي فالنسيا الدولي الإسباني ( باكو ألكاسير ) , وذلك خلال سوق الإنتقالات الصيفية الجارية حالياً لتعزيز وتدعيم صفوف الفريق هذا الموسم .

حيث اكد النادي الكتلوني عبر موقعه الإلكتروني على الإنترنت عن التوقيع مع النجم الإسباني باكو ألكاسير , بعقد يمتد حتى خمس سنوات قادمة أي حتى عام 2021 , كما وضع النادي شرط جزائي في عقد اللاعب قيمته 100 مليون يورو .

وأشار النادي الكتلوني في بيانه الرسمي على أن قيمة الصفقة 30 مليون يورو بالإضافة 2 مليون يورو كمتغيرات , وأكد النادي في بيانه على أن للاعب إجتاز الفحص الطبي بنجاح , على أن يتم تقديم اللاعب لوسائل الإعلام عقب إسبوع الفيفا .

يذكر ان باكو ألكاسير البالغ من العمر 23 عاماً كان قد إنتقال الى فالنسيا في عام 2013 قادماً من خيتافي , وتمكن اللاعب من المشاركة في 93 مباراة وسجل 30 هدفاً ومرر 13 كرة حاسمة لزملاءه في جميع المسابقات وفاز بـ36 مباراة .

2016-08-29

Top 4 Java Web Frameworks!!

Report page, brought for comparison
Back in May, we launched what proved to be our most popular investigation into Java developers tools and technologies: The Java Tools and Technologies Landscape for 2014. Propelled by a rush of charitable feelings, precisely 2164 JVM developers responded to the survey–each response donated 0.50 USD to Child’s Play, a charity that gives sick children game consoles to pass the time while sick.
One of the most popular subjects that we regularly cover has to do with Java Web Frameworks–after all, it’s one of the most active and fragmented technology segments out there. One in 10 devs we talked to doesn’t use any web frameworks at all, and one in five developers uses among 40 or web frameworks that aren’t even in the top 8 most used out there. What the heck is going on here?!
Here is what we’ll look at today:
  • How many developers use multiple frameworks?
  • Breakdowns for the top 4 frameworks compared to the average results (e.g. what % of Spring MVC users also use Vaadin?)
Let’s get started!

Nearly one-third (32%) of developers use more than one framework


how-many-web-frameworks-are-being-used
Java web frameworks are one of the few technology segments we looked into that really features complementary tools–as you can see, 57% use only 1 framework and 32% of all respondents (including those that use nothing) said they use 2 or more frameworks. That goes up to 36% when we eliminate non-users. As if to emphasize the fragmentation of this area, we see different results when we break it down based on the 4 frameworks we’re looking at today.

What % of specific framework users use more than one framework?

  • Spring MVC – 54%
  • JSF – 54%
  • Vaadin – 54%
  • GWT – 70%
It would seem that GWT is not the single framework of choice for our respondents. Let’s dig deeper into the figures for these four frameworks.

What percentage of a framework’s users also use something else?


frameworks-users-also-use-graph-modal-bigger

Spring MVC

Spring MVC users are strongly aligned with the overall findings–with Spring MVC in use by 40% of developers that use a web framework, this is not surprising. The top 4 frameworks used by Spring MVC users are JSF, Vaadin, GWT and Grails. Like a presidential election, we found the breakdown pretty much even: 54% of Spring MVC users also use another framework, but 46% stick only with Spring. Here are some other notable findings related to Spring MVC users:
  • Grails is the holy grail – Grails among Spring MVC users is 57% higher than the average, which is sensible considering that SpringSource acquired G2One, the company behind Groovy, back in 2008.
  • Struts 1 & 2 increased by nearly as much – The usage of Struts 1 & 2 among Spring MVC users is 54% higher than the average–16.2% compared to 10.5%. So, here are those Struts users that were considerably more prevalent in 2012! If these are mainly long-term Spring Framework users, then we can see the residual effect of the once-dominant Struts.
  • GWT one-third more popular – GWT usage among Spring MVC users is 34% higher than the average. In our previous coverage of Java Web Frameworks, we identified Spring and GWT as fitting together naturally, complementing each other’s strengths and reducing the deficiencies.

JSF

With the dominant positions generally held by Spring, Vaadin, GWT, they are still aligned with expectations, but among JSF users we see a resurgence in what some developers might think of “legacy frameworks” (perhaps “mature” is better): Seam especially, but also Struts 1 & 2 and Wicket are more highly represented among the JSF crowd, while newer players like Grails and Play 2 are less commonly used. Notably, we can see that:
  • Seam is about a billion% more popular – Barely reaching 2% of use by the average framework user, Seam usage among JSF users is 8%, a whopping four-fold increase comparatively.
  • Struts 1 & 2 is one-third higher – As with Spring MVC, JSF is also a well-known framework that most likely built friendships with Struts 1 and 2 users back in the day. These two frameworks are found 32% more often among JSF users.
  • Grails & Play 2 much less popular –  While Grails (7%) and Play 2 (6.5%) were more popular for the average framework user, JSF users are 53% less likely to use Grails (3.3%) and 59% less likely to use Play 2 (2.7%).

Vaadin

Vaadin has been one of the fastest-growing web frameworks out there, specializing in helping devs design attractive UIs. If there was ever a framework that seems to have taken all the real estate from Struts 1 & 2, it would be Vaadin. GWT in ourDecision Maker’s Guide to Java Web Frameworks (2014 edition), which we ranked as the #1 framework to use for Java development, although the main recommendation was to use several apply the strengths of several frameworks at once.
  • GWT usage greatly increased (but still not #1) –  With so many platform similarities, it’s not surprising to see GWT usage nearly double among Vaadin users compared to the average, but it’s still not in first place (held by Spring MVC). This reinforces our position in the Decision Makers report that Spring is used for its many strengths even when the dream-team Vaadin / GWT get together.
  • Struts, party of 2? Struts? Hello? Compared to the Spring MVC and JSF crowd, Struts 1 & 2 usage is 2-3 times lower among Vaadin users–not even 7% use Struts 1 & 2 combined compared to over 16% for Spring MVC and nearly 14% for JSF users.
  • Grails usage decreases by about 50% – Given that we ranked Vaadin and Grails nearly even in the frameworks report, it would seem they cancel each other out. Users need just one of them.

GWT

We’ve seen GWT decrease in market share since 2012, probably after the whole JavaScript security warning from Google. In fact, without the poor security surrounding JS, GWT scores relatively well, and when combined with an ultra-secure framework like Spring MVC, it’s a great combo. GWT users definitely utilize Vaadin, which is based on GWT at heart, but for some reason we see a large jump in Struts 1 usage.
  • Vaadin is the favorite – Vaadin usage by GWT users jumps by about 34% to take the #2 position vacated by JSF, which is used a lot less. More or less, they traded 2nd and 3rd places with each other when it comes to GWT users.
  • Um, Struts 1 makes a comeback? – Combined usage of Struts 1 & 2 is higher than average, but oddly it’s Struts 1 usage, not Struts 2, that increases by about 50% compared to the average.
  • Lowest % of Spring MVC users – Although it’s not much, GWT users take also use Spring MVC about 10% less than the 3 other frameworks, and 20% less than the average.

The “Take-aways” from this analysis

Ok, let’s sum up everything that we found in one good sentence about each section here. This should be good enough for a Too Long; Didn’t Read (TL;DR) spot:
  • Multiple framework usage is a common-enough occurrence, with nearly one-third (32%) of developers using 2 or more frameworks. Another 57% use just one framework, and 11% use nothing that appeared in our list (i.e. JSPs and Servlets all the way!)
  • Spring MVC users show higher usage of Grails via the ownership of the Groovy platform and Struts 1 & 2, most likely left over from mature projects, and GWT, which we see as a very complementary framework.
  • JSF users, compared to the report’s averages, are considerably more likely to use mature frameworks, namely Seam and Struts 1 & 2, while shunning newer technologies like Grails and Play 2.
  • Vaadin users seem to work alone, only showing increased usage compared to the average of GWT, on which it is built. Struts 1 & 2 usage drops significantly and comparable framework Grails is also much decreased.
  • In return, GWT users favor Vaadin over JSF, as well as Struts 1 for some inexplicable reason.
  • #copied
  • #Mahmoudelasry
  • mahmoudelasry2013@gmail.com

Send SMS Text Message with Java

The following example Java class, sendsms, can be used to send an SMS text message via NowSMS from Java. This script can also be downloaded from http://www.nowsms.com/download/sendsms.java.txt.


import java.net.*; 

import java.io.*; 



public class sendsms {

 



    public static String server;

    public static String user;

    public static String password;

    public static String phonenumber;

    public static String text;

    public static String data;

    public static String udh;

    public static String pid;

    public static String dcs;

    public static String sender;

    public static String validity;

    public static String servicetype;

    public static String smscroute;

    public static String receiptrequested;

    public static String sourceport;

    public static String destport;

    public static String delayuntil;

    public static String voicemail;

    public static String wapurl;

    public static String wapsl;



    public static String url_str;



    public static void init () {

        server = null;

        user = null;

        password = null;

        phonenumber = null;

        text = null;

        data = null;

        udh = null;

        pid = null;

        dcs = null;

        sender = null;

        validity = null;

        servicetype = null;

        smscroute = null;

        receiptrequested = null;

        sourceport = null;

        destport = null;

        delayuntil = null;

        voicemail = null;

        wapurl = null;

        wapsl = null;

    }



    public static void setvar (String argname, String argvalue) {



       if (argname != null) {

          if (argvalue != null) {

             url_str = url_str + "&" + argname + "=";

             try {

                String encoded = URLEncoder.encode (argvalue, "UTF-8");

                url_str = url_str + encoded;

             }

             catch (UnsupportedEncodingException e) {

                url_str = url_str + argvalue;

             }

          }

       }

           

    }



    public static String send () {





       String returnstring;

   

       returnstring = null;



       if (server == null) {

  	  System.out.println("sendsms.server value not set");

          return returnstring;

       }



       url_str = server + "?";

       setvar("user", user);

       setvar("password", password);

       setvar("phonenumber", phonenumber);

       setvar("text", text);

       setvar("data", data);

       setvar("udh", udh);

       setvar("pid", pid);

       setvar("dcs", dcs);

       setvar("sender", sender);

       setvar("validity", validity);

       setvar("servicetype", servicetype);

       setvar("smscroute", smscroute);

       setvar("receiptrequested", receiptrequested);

       setvar("sourceport", sourceport);

       setvar("destport", destport);

       setvar("delayuntil", delayuntil);

       setvar("voicemail", voicemail);

       setvar("wapurl", wapurl);

       setvar("wapsl", wapsl);



       try {

          URL url2=new URL(url_str); 



          HttpURLConnection connection = (HttpURLConnection) url2.openConnection(); 

          connection.setDoOutput(false); 

          connection.setDoInput(true); 



          String res=connection.getResponseMessage(); 

		

          System.out.println("Response Code  ->"+res); 

	

          int code = connection.getResponseCode () ; 

		

          if ( code == HttpURLConnection.HTTP_OK ) {

             //Get response data.

             BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));



             String str;

        

             while( null != ((str = in.readLine()))) {

                if (str.startsWith("MessageID=")) {  

                   returnstring = returnstring + str + "\r\n";

                   System.out.println(str);

                }

             }    

             connection.disconnect() ; 

          }

       }

       catch(IOException e) {

          System.out.println("unable to create new url"+e.getMessage());

       }

       return returnstring;

   }

}

The sendsms class defined in this example can be used to send simple SMS text messages, as well as many types of binary SMS messages, including WAP Push.
The class supports many of the URL parameters that are defined for NowSMS, and could easily be adapted to support additional parameters.
NowSMS URL parameters are supported as methods for the sendsms class, with method names matching the URL parameter names, except that all methods are in lower case.
In addition the URL parameter methods, the following additional methods are defined:
sendsms.init();
The init method initialise the SMS message object.
sendsms.server = "http://localhost:8800/";
The server method sets the URL address for the NowSMS server.
sendsms.send();
The send method submits the SMS message to NowSMS. (The send method returns a list of message ids assigned for the submitted message, with one message id per line, in the following format: MessageID=xxxxxxxxxxxxxx.req, Recipient=xxxxxxxxxxxx)
Supported methods for setting URL parameters:
sendsms.user = "username";
sendsms.password = "password";
These methods specify the authorisation credentials of the “SMS Users” account that is submitting the message.
sendsms.phonenumber = "recipient";
This method specifies the recipient phone number to which this message should be addressed. This can be a comma delimited list of recipient phone numbers or a distribution list name.
sendsms.text = "text of message";
This method specifies the text of the message. (Or for WAP Push messages, the text associated with the WAP Push URL.)
sendsms.data = "hexstring";
This method specifies a hex string of binary data for sending a binary SMS message.
sendsms.udh = "hexstring";
This method specifies a hex string of binary data for the User Data Header (UDH) of the SMS message.
sendsms.pid = "PID Value";
This method specifies a hex value representing the SMS Protocol ID (PID) of this SMS message.
sendsms.dcs = "DCS Value";
This method specifies a hex value representing the value of the SMS Data Coding Scheme (DCS) for this message.
sendsms.sender = "Sender";
This method specifies the sender (source) address to be specified for this message. (Note: It is not possible to override the sender address when sending messages via a GSM modem.)
sendsms.smscroute = "route name";
This method specifies an outbound SMSC route to be used for the message. (For more information on SMS message routing, see SMS Message Routing Logic.)
sendsms.receiptrequested = "Yes";
This method can be used to request a delivery receipt.
sendsms.sourceport = "3333";
sendsms.destport = "3333";
These methods can be used to specify source and destination ports for routing the SMS message to a specific application on the recipient mobile phone.
sendsms.delayuntil = "YYYYMMDDHHMM";
This method allows messages to be submitted to NowSMS and queued for later processing. The value of this parameter should be of the format “YYYYMMDDHHMM”, indicating the date and time until which the message should be delayed, where YYYY is the year, MM is the month, DD is the day, HH is the hour (in 24 hour format), and MM is the minutes.
sendsms.wapurl = "http://x/path";
Specifies that the a WAP Push message should be sent, and this is the URL to be sent in the WAP Push message.
Example – Sending a simple text message:
sendsms.init();
sendsms.server = "http://127.0.0.1:8800/";
sendsms.user = "test";
sendsms.password = "test";
sendsms.phonenumber = "+9999999999";
sendsms.text = "This is a test message";
sendsms.send();
Example – Sending a text message to a specific application port for a Java applet running on the phone:
sendsms.init();
sendsms.server = "http://127.0.0.1:8800/";
sendsms.user = "test";
sendsms.password = "test";
sendsms.phonenumber = "+9999999999";
sendsms.text = "This is a test message";
sendsms.destport = "3333";
sendsms.send();
Example – Sending a WAP Push Message:
sendsms.init();
sendsms.server = "http://127.0.0.1:8800/";
sendsms.user = "test";
sendsms.password = "test";
sendsms.phonenumber = "+9999999999";
sendsms.text = "This is a test message";
sendsms.wapurl = "http://www.nowsms.com/";
sendsms.send();

Java SE 8 new features tour: Calculating timespans with the new DateTime API




Cleaner, readable, and powerful coding with Java SE 8 New DateTime API JSR 310. ….


Java SE 8, JSR 310








In the previous article “Processing Collections with Streams API”; I have deeply dived into explanation, and exploration on how to traversing collections with streams, Creating streams from collections and arrays, and finally Aggregating stream values.In this article of the “Java SE 8 new features tour” series, we will deep dig into explanation, and exploring the code of JSR 310 specification, on how to Calculating timespans with the new DateTime API, Calculating time spans with Instant and Duration, Representing date and time values, Formatting date and time values, and Supporting time-zone offsets.

Source code is hosted on my Github account: clone it from here.

Table of Content:
Calculating time spans with Instant and Duration.
Representing date and time values.
Formatting date and time values.
Supporting time-zone offsets.
1- Calculating time spans with Instant and Duration:

Introduction:
Java SE 8 includes a complete new API for managing date and time values. The classes that actually hold the data in this new API are all immutable and thread safe. So that means you don’t have to worry about passing objects around in a multi threading environment. And if you’re using them in parallel streams, everything will always work perfectly. All of the classes in this new API are members of the packagejava.time. And I’ll start with two of the core classes named Instant and Duration.

How it works:
I’ll start with this example in the package eg.com.tm.java8.features.datetime.InstDuration of projectJava8Features. In a class code named InstantAndDuration. And I’ll place all this code inside the mainmethod. The first class I’ll describe is named Instant. I’ll type the name of the class and press Ctrl + Space, and choose the class from the java.time package, and it’s imported above. An instant object represents an instant on the Java timeline. Just as with the date class which is a part of the old way of managing dates and times, an instance represents a number of milliseconds.

Since the Java epoch time, January 1st 1970. To declare an instant object, I’ll declare it with its type, and give it a name of start. And then I’ll call a static method of the instant class called now(). And this represents the moment on the current machine when the code was called. Then I’ll output that value as a string, using standard system output. Run the code and you will see the output starting off with the date in year, month, date format and then the time after the letter T.

Result:

1 2016-08-05T21:21:59.601Z


Once you have a moment in time, you can use it to calculate a difference between that and another moment in time. So I’ll create another instant, which I’ll call end. And I’ll get it’s value from the method now() as well. Then I’ll use system output, and output that value. Notice that there is a slight difference between the two values, and that’s the amount of time it is taking on my system. To process this line of code, that’s outputting the start value.

Result:

1 2016-08-05T21:33:55.971Z


2 2016-08-05T21:33:56.048Z


If I were to move that line of code down, so I wasn’t doing any other processing between the two calls to the now method, the two values would be identical, Or they might be off by a thousandth of a second.

Result:

1 2016-08-05T21:34:43.365Z


2 2016-08-05T21:34:43.365Z


Now, I’ll show you how to calculate the difference between these two values. When you compare two instants to each other, you’ll get an object called a duration. It’s represented by the Duration class, which is also a member of Java.time. I’ll name this object elapsed. An I’ll call a static method of the duration class calledbetween(Temporal startInclusive, Temporal endExclusive). Notice that it’s looking for objects typed as something called Temporal. The Instant class is a sub-class of Temporal.

Result:

1 Elapsed: PT0S


I’ll pass in start and end as my two temporal values. And then I’ll output the difference. I’ll pass in a literal label of elapsed, and then I’ll pass in my variable. That duration object starts with the letter p and then t for time. This is again an ISO formatted value. And then it shows me zero seconds. Well let’s see what happens if we toss in a call to the sleep method. I’ll place the cursor here between the start and end calls. And I’ll use the Thread class.

I’ll press the period, and then press Ctrl+Space. And then I’ll call the sleep() method and pass in a value of 1,000. Meaning sleep for one second. The sleep method can throw an error, so I’ll use a quick fix, and I’ll add a throws declaration to the main methods signature. I’ll save and run the code, and I see that my lapse time is now 1.001 seconds. You can never really count on things being exact, it all depends on what’s going on, on the processing computer.

Result:

1 Elapsed: PT1.001S


Next, I’ll take this printline call, and move it back to its original location. So now after I get the start value, I’ll be executing a printline command. And I’ll be sleeping for one second. And I’ll run the code. And now my lapse time is 1.057 seconds.

Result:

1 2016-08-05T22:28:42.685Z


2 2016-08-05T22:28:43.769Z


3 Elapsed: PT1.084S


To make this a little bit more readable, I’ll add a call to the method of the duration object using elapsed.to millis. That means, get the milliseconds equivalent. And I’ll append to that, milliseconds, and I’ll run the code.

Result:

1 2016-08-05T22:32:52.657Z


2 2016-08-05T22:32:53.731Z


3 Elapsed: 1074 milliseconds


Conclusion:
And now I see, a readable value, of 1,054 milliseconds. So, that’s the Instant class and the Duration class. Two of the core classes, of the new date time API, in Java SE 8.
2- Representing date and time values:

Introduction:
I previously described how to use the instant class in the new date time API to represent a moment in the Java timeline. Here are three more useful classes to represent parts of dates and times. They’re called local date, local time, and local date time. Lets say, for example, that you only want to represent a date value. And you don’t care about times or seconds or milliseconds but only the current date. Create an instance of a class named LocalDate.
How it works:
I’m working in a package eg.com.tm.java8.features.datetime.localdt of project Java8Features. In a class code named LocalDateAndTime. with a main method. I’ll start with the name of the class LocalDate. And when I press Ctrl + Space, I’ll choose the class from the java.time package. I’ll name the objectcurrentDate and I’ll get its value with localDate.now. Notice that there’s consistency in the syntax between working with an instant, a date, a time and a date time.

To get the current value on the current machine, you always use the now method. Now, I’ll output that date in its default format. I’ll save and run the code, and it shows me the date in year-month-date format.

Result:

1 2016-08-06


You can also create a date object using specific year, month, and date values. Once again, I’ll create an object typed as LocalDate. And I’ll name this one specificDate. To get this value, call LocalDate.of.

And there are a couple of available versions. I’m going to use the one that takes three integer values. They aren’t named in the documentation but they represent the year, the month, and the day. I’ll patch in the values of 2,000, 1, and 1. Now, in the older version of the date time API using the date class. When you were dealing with months, you always had to do it with a 0 based off set. So for January you’d use 0, for February 1 and so on.

And that wasn’t particularly intuitive. In the new day time API, everything is 1 based. So 1 means January, 2 means February and so on. Just as you would normally expect.

I’ll once again use system output, and this time I’ll, I’ll put the new specific date. And when I save and run that, I get the value that I put in, January 1st, 2000.

Result:

1 2016-01-01


If you only want to represent a time value, use the LocalTime class, I’ll type the name of the class and import it, I’ll name the object currentTime and I’ll get its value from LocalTime.now.

Again, using the same sort of syntax as with localdate and with instant. Then I’ll use system output. And I’ll output that current time. The default value for the time is in 24 hour notation, and it shows the hour, the minute, the second, and the milliseconds.

Result:

1 01:18:11.779


I’ll use LocalTime. I’ll name this specificTime. And, just as with the local date class, I’ll call the method named of. Again, there are a number of different versions taking varying numbers of arguments.

I’ll use the version that’s looking for three integer values and I’ll type in 14, 0 and 45. And then I’ll output that value to the console. And there’s the result. 14, 00 and 45 seconds. Notice that because I didn’t provide a milliseconds value the formatted version of that time doesn’t show values after the dot.

Result:

1 14:00:45


Finally, I’ll show how to use the LocalDateTime class.

I’ll type the name of the class and import it. I’ll name this object currentDT. And I’ll get its value fromLocalDateTime.now. When you output a date time value, you’ll get a long format ISO date time. Starting with the date, and ending with the time. And if there are milliseconds in the value, they’ll be displayed. And finally, I’ll create a specific date, time and I’ll do this by combining my specific date and my specific time.

That code will look like the next code. I’ll create a LocalDateTime object. I’ll name it, specificDT and I’ll callLocalDateTime.of again. And this time, I’ll use this first version of the method that accepts a local date object and a local time object. You can also construct your date time value from combinations of years, months, dates, and time values. I’ll pass in my specific date and my specific time. And then I’ll output it to the console. And when I run that code, my specific date time is a combination of my specific date and my specific time.

Result:

1 2016-08-06T01:30:46.625


2 2016-01-01T14:00:45


Conclusion:
So, those are the three classes that you can use to represent date and time values on the local machine in the current time zone. There are also classes you can use to get time zone sensitive values. And I’ll describe those next.
3- Formatting date and time values:

Introduction:
I’ve previously described how to use the LocalDate, LocalTime, and LocalDateTime classes to represent time values. To present this information to a user, you’ll need to format it. And for that purpose, there’s a new class named DateTimeFormatter. I’ll show you how to create formatters using some simple syntax. And then how to do very custom work using a class called Daytime Formatter Builder.

How it works:
I’m working in a package eg.com.tm.java8.features.datetime.format of project Java8Features. In a class code named DateTimeFormater. with a main method.

First, I’ll create a date. I’ll give it a type of LocalDate, making sure to import that class. And I’ll name itcurrentDate. And I’ll get its value from LocalDate.now. Next I’ll create a formatter object. I’ll type the name of the class, DateTimeFormatter, and select it from the java.time.format package. I’ll name this object df. Now there are a number of ways of creating a formatter. One of the simplest is to use a constant of theDateTmeFormatter class.

I’ll once again type in DateTimeFormatter. And then after I type in the period I see a list of all of the available constants. I’ll choose ISO Date. And this will provide the default formatting for this object. Then, I’ll use System Output. I’ll call the formatted object format method and pass in the date object. And here is the result. I’m outputting the value in year month date format. With the month and the date padded out to two characters each. Now you can do the same sort of thing with times and date times.

Result:

1 2016-08-06


I’ll take above bit of code and I’ll duplicate it a couple of times and I’ll make some changes. In the second version, I’ll change the type from local date to local time. The object name to current time, and the name of the class I’m using to get the value to local time. I’ll change the name of the date time formatter from DF to TF for time formatter. And I’ll change the constant I’m using to ISO Time. And then I’ll change the object that I’m formatting. I’ll be sure to import the LocalTime class.

And then I’ll make similar changes to the third version. The class that I’ll be working with this time isLocalDateTime. I’ll be sure to import it. I’ll name this object, current DT. And I’ll change the class that I’m calling the now method from. I’ll change the formatter to DTF for DateTimeFormatter. And I’ll change the constant to ISO Date Time. And then I’ll format the current DT object. I’ll be sure I’m using the right formatters in each version of the code. I’ll save the change, and run the code.

And there are the three formatted values. Now so far, I haven’t really accomplished that much, because I’ve used the constants that represent the default formatting. But let’s take a look at some custom formats that are available.

Result:

1 2016-08-09


2 20:37:11.535


3 2016-08-09T20:37:11.538


I move down to below the existing code. And i’ll create another DateTimeFormatter, i’ll name this one f_longfor the long date format and i’ll get its value by calling a method of the DateTimeFormatter class called a Localised Date.

Notice that there are methods for date, time and date-time, with a variety of arguments. I’ll choose this one, of localized date, and I’ll pass in a constant of a class called, FormatStyle. Be sure to import this class. And then after you type the period, you’ll see that there are four constants available. Full, long, medium and short. I’ll choose the long version and then I’ll output the formatted date by calling F _ long.format and I’ll pass in the current DT object.

When i run this code i get the long version of the date.

Result:

1 August 9, 2016


I’ll show you another version of this by duplicating these two lines of code and for this version i’ll change the formatter name to f_short, i’ll change the constant I’m using to short also. And I’ll change the name of the formatter that I’m calling. So the long version is the name of the months spelled out. A comma after the date, and then the year in four digit format, and the short version at least for the current locale, is the month and date, without padding, with slashes separating values, and a two character year.

Result:

1 8/9/16


And next, I’ll show you how to use locales. I’ll create a couple of strings. The first will be called fr_ short, for French, in short format. To get that value i’ll call my f_short formatter and then i’ll will call method namewithLocal(). To get a locale value i’ll use the Local class, this is an existing class that’s been available inprevious versions of Java. It’s a member of the package Java.util.

And then, I can call one of the many constants representing various locales. I’ll use French. And then from there, I’ll call the format method, and pass in the current date time.

I’ll duplicate that line of code and for this version I’ll use fr_long. I’ll use the long formatter and otherwise the code will be the same. And then I will output those two values fr_short and fr_long.

And here’s the result. Notice for fr_short that the month and the day are reversed from the US version. And that’s because in Europe, the date is stated first, and then the month, and then the year. And when I use the long version I get the months spelled in French.

Result:

1 09/08/16


2 9 août 2016


Finally I’ll show you how to build completely custom formatters using a class called the date time formatter builder. It uses the builder design pattern, where you can call multiple methods, each returning an instance of the current builder.

I’ll type the name of the class and make sure that it’s been imported. And I’ll name the object b. I’ll instantiate it with the new keyword, and the constructor method.

Now, at the end of that code I won’t put in the semicolon because I want to immediately call a series of methods that let me build the formatter from scratch. I’ll start with a method named Append Value. Notice there’s Append Instant, Append Literal, Append Localized and many many others. I’m going to call a method named appendValue() that accepts an instance of a class named TemporalField and then I’ll use an enumerator named ChronoField. Which is extended from that TemporalField.

And from there I’ll use a constant name month of the year. Next I will append a literal value. This can be any character or any string. And just to make this thoroughly unique, I’ll put in a couple of pipe characters. Now I’ll take these two lines of code and duplicate them for the second version instead of month of year. I’ll put in day of month. Notice there’s also day of week and day of year. Then I’ll duplicate that line of code and move it down. And I’ll finish the expression with ChronoField.year.

Once you’ve created the builder object, you can get the formatter. I’ll create new object, typed asDateTimeFormatter. I’ll name it f for Formatter. And called builder objects, to formatter methods, and then finally I’ll format the current date time value. I’ll use system output and call f.format(), and pass incurrentDT.

And now when I run my code, I get completely customized format.

Result:

1 222||9||2016


Conclusion:
You can use the DateTimeFormatter builder to build any format you like. And because it uses the builder design pattern, it’s easy to create and to maintain the code.
4- Supporting time-zone offsets:

Introduction:
The new date time API offers a number of classes that let you manage time zones. Creating day time objects that are offset from Greenwich Mean Time, by certain number of hours, or by particular locations, and calculating differences between time zones.

How it works:
I’m working in a package eg.com.tm.java8.features.datetime.zone of project Java8Features. In a class code named TimeZones. with a main method.

In its main method, I’ve created a DateTimeFormatter and a LocalDateTime object. The LocalDateTimerepresents the current date and time on my system, in my time zone. And that’s Egyptian Time because I’m on the Middle East.

And then I’m outputting a formatted value to the console. I’m outputting the value using a short format. And in Egypt notation, it’s month, day and year.

Result:

1 8/9/16 10:22 PM


In order to represent a time zone based date time value, use the class ZonedDateTime. Just likeLocalDateTime, it’s immutable and thread safe. I’ll type the name of the class, and then press Control + Space to add the import statement. And I’ll name the object gmt for Greenwich Mean Time.

There are a few different ways of creating this object. I’ll show you how to create the object calculating an offset from Greenwich Mean Time. I’ll use the ZonedDateTime class again, and after I type the period, I’ll see that there are many methods available. I can call now() again, to get the date time value in my area. I can call of() methods that let me do various calculations. I can parse strings, but I’m going to use this version of the now method. I’ll pass in an instance of the ZoneId class.

A ZoneId represents a certain number of hours offset from Greenwich Mean Time. And I’ll get that value by calling a method named ZoneId.of(). And I’ll pass in a literal string of “GMT+0”. That means, show me the current date and time value in Greenwich Mean Time.

Now I’ll duplicate my code that’s outputting the value to the console. I’ll move that down, and I’ll change this version to output gmt. I’ll run the code, and there’s the result.

Result:

1 8/9/16 8:28 PM


I’m in the Middle East Egypt, and right now, Greenwich Mean Time is two hours ahead.

Here is another approach to getting a ZonedDateTime. Lets say you wanted to get the ZoneDateTime in New York. There are many built-in strings, or constants, that will let you name particular locations, and you’ll get back the correct ZoneId for that location, and you won’t have to worry about the math yourself. I’ll create another ZonedDateTime object, and this time i’ll name it ny for New York, and I’ll get it value by callingZonedDateTime.now(), and again I’ll pass in ZoneId.of(), but this time i’ll pass in a string ofAmerica/New_York.

Make sure to spell this string exactly as you see it here. I’ll create a line of code to output that value. I’ll save the change, and run it. And New York is on East Coast time, three hours ahead of Pacific time.

Result:

1 8/9/16 4:36 PM


To find out about all of the available strings, you can call a method of the ZoneId class calledgetAvailableZoneIds(). You’ll get back a set. I’ll type Set and press Control + Space, and then choose set from Java.util.

And I’ll set the generic type of the items in this set to String. I’m name the set zones. And then I’ll call the method, ZoneId.getAvailableZoneIds. Then I’ll loop through the strings with the forEach() method. And then I’ll pass in a Lambda expression. So I can deal with each of the items in turn.

Result:
When I run that code, I see all of the available strings.

01 Asia/Aden


02 America/Cuiaba


03 Etc/GMT+9


04 Etc/GMT+8


05 Africa/Nairobi


06 America/Marigot


07 Asia/Aqtau


08 Pacific/Kwajalein


09 America/El_Salvador


10 Asia/Pontianak


11 Africa/Cairo


12 Pacific/Pago_Pago


13 Africa/Mbabane


14 Asia/Kuching


15 Pacific/Honolulu


16 Pacific/Rarotonga


17 America/Guatemala


18 Australia/Hobart


19 Europe/London


20 America/Belize


21 America/Panama


22 Asia/Chungking


23 America/Managua


24 America/Indiana/Petersburg


25 Asia/Yerevan


26 Europe/Brussels


27 GMT


28 Europe/Warsaw


29 America/Chicago


30 Asia/Kashgar


31 Chile/Continental


32 Pacific/Yap


33 CET


34 Etc/GMT-1


35 Etc/GMT-0


36 Europe/Jersey


37 America/Tegucigalpa


38 Etc/GMT-5


39 Europe/Istanbul


40 America/Eirunepe


41 Etc/GMT-4


42 America/Miquelon


43 Etc/GMT-3


44 Europe/Luxembourg


45 Etc/GMT-2


46 Etc/GMT-9


47 America/Argentina/Catamarca


48 Etc/GMT-8


49 Etc/GMT-7


50 .................


Now, there are so many it might be hard to find the one that you’re looking for. So let’s say that I wanted to look for London.

And use the time zone for that particular location, at this particular time of year. As I showed earlier in the article, I could use a predicate to search the strings. I’ll create a predicate object. And I’ll set the generic type to String. And I’ll name the object condition. Then I’ll implement the predicate with a lambda expression. I’ll pass in str, and then I’ll implement the predicate with a condition. str.contains, and I’ll pass in a string of London.

Then I’ll refactor my Lamba expression. I’m going to wrap System.out.println() in braces. Then I’ll expand the code to make it a little bit easier to work with. I’ll add the semi colon at the end of the print line, and then I’ll create an if statement. And I’ll set the condition to condition.test(), and I’ll pass in z for the current zone. I’ll move the println() statement, to within the condition, and now i’ll only printout strings that match my predicate test.

I’ll save the change and run the code, and there’s the result. I find that the correct string for London is:

Result:

1 Europe/London


Conclusion:
So that’s a little bit about working with time zones. Again, use the ZonedDateTime class instead ofLocalDateTime to represent values that you can modify and calculate against. The ZoneId represents an off set from Greenwich Mean Time. And there’s also a class called Zone Offset that you can use to calculate different time zones against each other.
#copied

So, Oracle killed java.net

Well, not yet…but they announced to shutdown java.net and kenai by May 2017. I have been interviewed about this for an ADTmag article The ‘Sunsetting’ of Kenai and java.net by John K. Waters.
As Oracle provided little information to what will happen to critical projects that are already hosted on java.net, most of what was written in the article is still valid. Therefore I’m reposting my comments here again.
There have been discussions over several years about the future of java.net and kenai.com, as there was very little improvement in both of them to keep up with modern trends. Therefore it made sense to reconsider what role they are playing in the Java ecosystem. However, the way Oracle announced the plan to shut them down makes many members of the community wonder whether it was carefully planned or just a desire to cut costs and shut down projects they cannot monetize. The latter is more likely, as even many people from Oracle, who stand behind existing projects hosted onjava.net, don’t yet have a plan how to migrate their project to somewhere else.
There are many valuable resources on both java.net and kenai.com, including project sources and documentation, forums, blogs, and other sorts of information like JUG profiles and documents. The announcement poses high risk that certain amount of that information will be lost after the shut down of both sites. We can remember the losses from recent history, when all sun.com sites were migrated under oracle domains, but not all links are properly redirected to date. People would say the internet has very good memory, but it can also forget badly when a site like java.net goes down completely.
As a member of the Java and Java EE community, I would appreciate if Oracle provided at least a simple replacement for both sites, which would be a unified portal for all Java community members and opensource projects, while relying on other common services like GitHub for the necessary infrastructure. Something likeplugins.netbeans.org does for Netbeans community, or www.codeplex.com does for Microsoft opensource community. The effort is ongoing with community.oracle.com, so hopefully soon enough this new Oracle community page will be able to provide all what is necessary to bring the community together.
The important fact to point out here is that java.net has been a standard place to host all the official resources for most Java EE JSRs, including project sites, history of public communication on mailing lists, tracked issues, sources of the reference implementations. If java.net was shut down right now, it would practically mean death to Java EE, or in better case a hibernation lasting for many months.This is the reason why I joined Java EE Guardians, who intend to keep reminding this fact to the Oracle, the JCP board and JSR specification leads and actively offer our cooperation in finding a new home for all JSRs and related projects. It has to be ensured that no valuable resources are lost and that the new tools and hosting is even more appropriate than current solutions. In the end, if that is accomplished, we can all benefit from making the Java EE process more transparent and accessible to even wider community.

2016-08-14

The Story of Smokling with the American Giant Pheleps

سنه ٢٠٠٨ في طفل اسمه سكولنج من سنغافورا اتصور مع مايكل فيليبس السباح الاسطوري لانه بيحبه ونفسه يبقي زيه .
النهارده سكولنج وصل للاوليمبيات ولاعب مايكل فيليبس وكسبه وحطم رقمه الأوليمبي وأخد هو الميداليه الذهبيه ومايكل خد الفضيه .


2016-08-10

Job Vacancies

We are hiring .... 

- Web Designer - System Analyst Team Leader - System Analyst - Senior CRM Developer - Senior CRM Analyst - Software Quality Control - Database Administrator - Senior Web Developer - Business Intelligence Developer 

 

Location : Alexandria, Egypt 

 If you are interested to join our team ,
find this available vacancies: 
 Send your CV To : TagElMaaly.Mohamed@Andalusiagroup.net
mention Job title in subject.