Tuesday 15 April 2014

parsing - Joda Time complex operations on time -


I want to use the add time in my project. I would love to know how to use it. The idea is. First of all - I want to make a progress bar which I init and then calculate every second of its value - it shows me spending time to complete the process.

In the initial form, I only represent the time remaining and percentage in the string format "HH: mm: SS" (periodically "D-Day HH: mm: SS") - progress bar preliminary stage. I have all this.

I now want to create a datetime object that represents the moment of completion of the work.

  PeriodFormatter timeFormatter = New PeriodFormatterBuilder () .appendHours () .appendSeparator (":"). Attachment () .appendSeparator (":"). AppendSeconds (). ToFormatter (); Date expiration date = new date (); Duration length = faucet; String [] parsedinput = timelift. Split (""); If (ParsedInput! = Null) {Switch (ParsedInput.log) {Case 1: {Duration lift = Timeformer. Peer period (perused input [0]); EndDate_.plus (periodLeft); break; } Case 3: {periodLeft = timeFormatter.parsePeriod (ParsedInput [2]); PeriodLeft.plusDays (Integer.parseInt (parsedInput [0])); EndDate_.plus (periodLeft); break; } Default: Break; }}   

As far as I understand, now I have what I wanted, right? Now I want to calculate the total duration of the process. This is the reason why I change this period in milliseconds and calculate the total duration based on progress: long duration = (duration lift.derddirection (). GetMillis () * 100 ) / (Progress == 0 1: progress);

Now I have to implement a method that gives the actual status of the process based on the present time. How can I achieve that? I know the time, so I can get the start date time. Then I can simply compare the start date and date count to date: (now - start) / period_ * 100. But how do I get the start date?

Using the time is very easy and you do not need to fill your code with formats that you Want to The process you are measuring should start at some points of your code and this is where you should pay attention to your starting time. Try to do something like that.

  DateTime start time = date time.NEW (); Date timeout time = date time.NEW (); EndTime.plusSeconds (50); // Write code for your application. Sleep (3000); // Calculate your percentage double balance display = (date time.nu () () .million () - starttime.gatas ()) / (endtime.gatimilis () - datetime no (). Millimilis ()) * 100 ; // Then output the date using the string method. EndTime.toString ("MMM DD yy");    

No comments:

Post a Comment