2017-02-25 33 views
1

das ist mein Countdown-Code. Ich frage mich, wie ich zum Beispiel Freitage oder Samstage von meinem Code ausschließen kann. Danke im Voraus.Wie man Freitage auf meinem Countdown ausschließt

 public void run() { 
      handler.postDelayed(this, 1000); 
      try { 
       SimpleDateFormat dateFormat = new SimpleDateFormat(
         "yyyy-MM-dd"); 
       // Event Date 
       Date futureDate = dateFormat.parse("2017-4-2"); 
       Date currentDate = new Date(); 
       if (!currentDate.after(futureDate)) { 
        long diff = futureDate.getTime() 
          - currentDate.getTime(); 
        long days = diff/(24 * 60 * 60 * 1000); 
        diff -= days * (24 * 60 * 60 * 1000); 
        long hours = diff/(60 * 60 * 1000); 
        diff -= hours * (60 * 60 * 1000); 
        long minutes = diff/(60 * 1000); 
        diff -= minutes * (60 * 1000); 
        long seconds = diff/1000; 

Rest des Codes gelöscht.

+0

Bitte geben Sie alle Informationen an –

Antwort

0

Nur sehen, wie viele Freitage oder Samstage sind da und subtrahieren sie vom Countdown.

0
//Plain java 
    Calendar calendar = Calendar.getInstance(); 
    //The date that you want to check 
    calendar.setTime(currentDate); 
    //Filter Friday and Saturday 
    if(!calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY 
      && !calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY){ 
     //process the date 
    } 


    //Using Joda time 
    LocalDate theDate= new LocalDate(2016, 11, 12); //12 Nov 2016 
    int dayOfTheWeek = theDate.dayOfWeek().get(); //an integer, representing the day of the week 

    if (!DateTimeConstants.FRIDAY== dayOfTheWeek 
       &&!DateTimeConstants.SATURDAY== dayOfTheWeek) { 

    } 
Verwandte Themen