Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7900421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:58:00+00:00 2026-06-03T08:58:00+00:00

I have a stax doc with some embedded scripting to check if today’s day

  • 0

I have a stax doc with some embedded scripting to check if today’s day is a Wed or Sat, after initial formatting the correct day is printed to screen but in the find() method “Wed” is always printed to screen, even on a Sat. Is there a better way to do this compare?
jython code can be run within the script

import java.util.Date
import java.util.Calendar
import java.text.SimpleDateFormat

now = java.util.Date()
dayFormat = java.text.SimpleDateFormat('EEE')
cal = java.util.Calendar.getInstance();  
cal.setTime(now);  
cal.add(java.util.Calendar.HOUR, 5);
dayBeforeFormat = cal.getTime();

day = str(dayFormat.format(dayBeforeFormat))
print(day)


if day.find('Sat'):
    print('Sat')
elif day.find('Wed'):
    print('Wed')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:58:01+00:00Added an answer on June 3, 2026 at 8:58 am

    When the code runs on a Saturday, the value of day is “Sat” and this bit:

    day.find('Sat')
    

    returns 0. This is the lowest index in the day string where the substring “Sat” is found. See http://www.jython.org/docs/library/stdtypes.html#string-methods.

    0 is equivalent to boolean False.

    This will work:

    if day.find('Sat') > -1:
        print('Sat')
    

    Or simpler:

    if day == 'Sat':
        print('Sat')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one doubt regarding xml reading using Stax Parser. Expected Result: hq_seq_mast {SEQ_VAL=SEQ_VAL,
I have code to fetch characters from a StAX parser using eventReader. The code
Have some code: using (var ctx = new testDataContext()) { var options = new
I have a class which encapsulates a StAX Writer for a special business XML
Have some dates in my local Oracle 11g database that are in this format:
Have you any idea how to find out if spell check suggestions dialog is
I have taken over the maintenance of an application that uses a stax parser
Have a rails app that is supposed to display a list of products/managers. After
Have a nice day! How to use NPAPI plugin written on C++ in Windows
Have a painfully simple blog Post creator, and I'm trying to check if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.