Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public Calendar getSpnCal(){
  2.  
  3. //getting spn cal date for stamp use
  4. Calendar cal = Calendar.getInstance();
  5.  
  6. int index = spnArr.get(0).getSelectedItemPosition();
  7. //adjusts week_of_year to actual week_of_year
  8. cal.set(Calendar.WEEK_OF_YEAR, index + firstWeek + 1);
  9. cal.getTime();
  10.  
  11. index = spnArr.get(1).getSelectedItemPosition();
  12. //adjusts spinner index to DAY_OF_WEEK index
  13. cal.set(Calendar.DAY_OF_WEEK, index + 1);
  14. cal.getTime();
  15.  
  16.  
  17.  
  18. index = spnArr.get(2).getSelectedItemPosition()+1;
  19. cal.set(Calendar.HOUR_OF_DAY, index);
  20. cal.getTime();
  21. //^^sometimes this just doesn't work
  22.  
  23. index = spnArr.get(4).getSelectedItemPosition();
  24. cal.set(Calendar.AM_PM, index);
  25. cal.getTime();
  26. //^^^^sometimes this changes the hour
  27.  
  28. index = spnArr.get(3).getSelectedItemPosition();
  29. cal.set(Calendar.MINUTE, index);
  30. cal.getTime();
  31.  
  32.  
  33.  
  34. //only care about whole minutes and extra seconds can throw off calculations
  35. cal.set(Calendar.SECOND, 0);
  36. cal.getTime();
  37. return cal;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement