Returns a fancy duration up to Years @param duration the duration in ms @return the fancy duration
(RollingSequence rollingSequence, long duration)
| 319 | * @return the fancy duration |
| 320 | */ |
| 321 | public static String duration(RollingSequence rollingSequence, long duration) { |
| 322 | String suffix = "Millisecond"; |
| 323 | double phantom = duration; |
| 324 | int div = 1000; |
| 325 | |
| 326 | if (phantom > div) { |
| 327 | phantom /= div; |
| 328 | suffix = "Second"; |
| 329 | div = 60; |
| 330 | |
| 331 | if (phantom > div) { |
| 332 | phantom /= div; |
| 333 | suffix = "Minute"; |
| 334 | |
| 335 | if (phantom > div) { |
| 336 | phantom /= div; |
| 337 | suffix = "Hour"; |
| 338 | div = 24; |
| 339 | |
| 340 | if (phantom > 24) { |
| 341 | phantom /= div; |
| 342 | suffix = "Day"; |
| 343 | div = 7; |
| 344 | |
| 345 | if (phantom > div) { |
| 346 | phantom /= div; |
| 347 | suffix = "Week"; |
| 348 | div = 4; |
| 349 | |
| 350 | if (phantom > div) { |
| 351 | phantom /= div; |
| 352 | suffix = "Month"; |
| 353 | div = 12; |
| 354 | |
| 355 | if (phantom > div) { |
| 356 | phantom /= div; |
| 357 | suffix = "Year"; |
| 358 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 359 | } else { |
| 360 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 361 | } |
| 362 | } else { |
| 363 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 364 | } |
| 365 | } else { |
| 366 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 367 | } |
| 368 | } else { |
| 369 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 370 | } |
| 371 | } else { |
| 372 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 373 | } |
| 374 | } else { |
| 375 | return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); |
| 376 | } |
| 377 | } else { |
| 378 | return "Under a Second"; |