How to get week of year and week of month in Jalali (Shamsi) calendar












-2















I need to get the week of year and week of the month in Jalali (Shamsi) calendar. Is there a library or snippet of code to do that?



I used JalaliCalendar, but it only has the week of the year



System.out.println(JalaliCalendar.weekOfYear(32,1397));


I want to have the week of the month too.



Update:



I use below library:
https://github.com/razeghi71/JalaliCalendar/










share|improve this question

























  • What is your JalaliCalender library address? There are plenty of them on Github.

    – hamid ghasemi
    Jan 1 at 13:46








  • 1





    Possible duplicate of A good date converter for Jalali Calendar in Java?

    – oleg.cherednik
    Jan 1 at 14:09











  • @oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

    – Mohammad Javadi
    Jan 1 at 14:39
















-2















I need to get the week of year and week of the month in Jalali (Shamsi) calendar. Is there a library or snippet of code to do that?



I used JalaliCalendar, but it only has the week of the year



System.out.println(JalaliCalendar.weekOfYear(32,1397));


I want to have the week of the month too.



Update:



I use below library:
https://github.com/razeghi71/JalaliCalendar/










share|improve this question

























  • What is your JalaliCalender library address? There are plenty of them on Github.

    – hamid ghasemi
    Jan 1 at 13:46








  • 1





    Possible duplicate of A good date converter for Jalali Calendar in Java?

    – oleg.cherednik
    Jan 1 at 14:09











  • @oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

    – Mohammad Javadi
    Jan 1 at 14:39














-2












-2








-2








I need to get the week of year and week of the month in Jalali (Shamsi) calendar. Is there a library or snippet of code to do that?



I used JalaliCalendar, but it only has the week of the year



System.out.println(JalaliCalendar.weekOfYear(32,1397));


I want to have the week of the month too.



Update:



I use below library:
https://github.com/razeghi71/JalaliCalendar/










share|improve this question
















I need to get the week of year and week of the month in Jalali (Shamsi) calendar. Is there a library or snippet of code to do that?



I used JalaliCalendar, but it only has the week of the year



System.out.println(JalaliCalendar.weekOfYear(32,1397));


I want to have the week of the month too.



Update:



I use below library:
https://github.com/razeghi71/JalaliCalendar/







java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 13:53







Mohammad Javadi

















asked Jan 1 at 13:41









Mohammad JavadiMohammad Javadi

82




82













  • What is your JalaliCalender library address? There are plenty of them on Github.

    – hamid ghasemi
    Jan 1 at 13:46








  • 1





    Possible duplicate of A good date converter for Jalali Calendar in Java?

    – oleg.cherednik
    Jan 1 at 14:09











  • @oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

    – Mohammad Javadi
    Jan 1 at 14:39



















  • What is your JalaliCalender library address? There are plenty of them on Github.

    – hamid ghasemi
    Jan 1 at 13:46








  • 1





    Possible duplicate of A good date converter for Jalali Calendar in Java?

    – oleg.cherednik
    Jan 1 at 14:09











  • @oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

    – Mohammad Javadi
    Jan 1 at 14:39

















What is your JalaliCalender library address? There are plenty of them on Github.

– hamid ghasemi
Jan 1 at 13:46







What is your JalaliCalender library address? There are plenty of them on Github.

– hamid ghasemi
Jan 1 at 13:46






1




1





Possible duplicate of A good date converter for Jalali Calendar in Java?

– oleg.cherednik
Jan 1 at 14:09





Possible duplicate of A good date converter for Jalali Calendar in Java?

– oleg.cherednik
Jan 1 at 14:09













@oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

– Mohammad Javadi
Jan 1 at 14:39





@oleg.cherednik : it's not. I want to get a specific feature, not just a date convertor.

– Mohammad Javadi
Jan 1 at 14:39












1 Answer
1






active

oldest

votes


















1














I suggest you com.ibm.icu. It contains an awesome library for Jalali calendar.



If your project is a maven based, you can use the following dependency:



<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>59.1</version>
</dependency>


And this is a sample use of Persian calendar:



//configuration
ULocale locale = new ULocale("@calendar=persian");
Calendar calendar = Calendar.getInstance(locale);
calendar.setFirstDayOfWeek(7); //Make Saturdays first day of the week.

//usage
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int weekOfYear = (calendar.get(Calendar.YEAR_WOY) == year)? calendar.get(Calendar.WEEK_OF_YEAR) : 53;
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);


It is important to know Calendar and ULocale are from com.ibm.icu.util.Calendar and com.ibm.icu.util.ULocale. NOT java.util.



If you have any problem in understanding the code, do not hesitate to ask.






share|improve this answer


























  • Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

    – Mohammad Javadi
    Jan 1 at 14:06











  • @MohammadJavadi Code changed to java.

    – hamid ghasemi
    Jan 1 at 14:18











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995930%2fhow-to-get-week-of-year-and-week-of-month-in-jalali-shamsi-calendar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I suggest you com.ibm.icu. It contains an awesome library for Jalali calendar.



If your project is a maven based, you can use the following dependency:



<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>59.1</version>
</dependency>


And this is a sample use of Persian calendar:



//configuration
ULocale locale = new ULocale("@calendar=persian");
Calendar calendar = Calendar.getInstance(locale);
calendar.setFirstDayOfWeek(7); //Make Saturdays first day of the week.

//usage
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int weekOfYear = (calendar.get(Calendar.YEAR_WOY) == year)? calendar.get(Calendar.WEEK_OF_YEAR) : 53;
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);


It is important to know Calendar and ULocale are from com.ibm.icu.util.Calendar and com.ibm.icu.util.ULocale. NOT java.util.



If you have any problem in understanding the code, do not hesitate to ask.






share|improve this answer


























  • Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

    – Mohammad Javadi
    Jan 1 at 14:06











  • @MohammadJavadi Code changed to java.

    – hamid ghasemi
    Jan 1 at 14:18
















1














I suggest you com.ibm.icu. It contains an awesome library for Jalali calendar.



If your project is a maven based, you can use the following dependency:



<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>59.1</version>
</dependency>


And this is a sample use of Persian calendar:



//configuration
ULocale locale = new ULocale("@calendar=persian");
Calendar calendar = Calendar.getInstance(locale);
calendar.setFirstDayOfWeek(7); //Make Saturdays first day of the week.

//usage
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int weekOfYear = (calendar.get(Calendar.YEAR_WOY) == year)? calendar.get(Calendar.WEEK_OF_YEAR) : 53;
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);


It is important to know Calendar and ULocale are from com.ibm.icu.util.Calendar and com.ibm.icu.util.ULocale. NOT java.util.



If you have any problem in understanding the code, do not hesitate to ask.






share|improve this answer


























  • Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

    – Mohammad Javadi
    Jan 1 at 14:06











  • @MohammadJavadi Code changed to java.

    – hamid ghasemi
    Jan 1 at 14:18














1












1








1







I suggest you com.ibm.icu. It contains an awesome library for Jalali calendar.



If your project is a maven based, you can use the following dependency:



<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>59.1</version>
</dependency>


And this is a sample use of Persian calendar:



//configuration
ULocale locale = new ULocale("@calendar=persian");
Calendar calendar = Calendar.getInstance(locale);
calendar.setFirstDayOfWeek(7); //Make Saturdays first day of the week.

//usage
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int weekOfYear = (calendar.get(Calendar.YEAR_WOY) == year)? calendar.get(Calendar.WEEK_OF_YEAR) : 53;
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);


It is important to know Calendar and ULocale are from com.ibm.icu.util.Calendar and com.ibm.icu.util.ULocale. NOT java.util.



If you have any problem in understanding the code, do not hesitate to ask.






share|improve this answer















I suggest you com.ibm.icu. It contains an awesome library for Jalali calendar.



If your project is a maven based, you can use the following dependency:



<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>59.1</version>
</dependency>


And this is a sample use of Persian calendar:



//configuration
ULocale locale = new ULocale("@calendar=persian");
Calendar calendar = Calendar.getInstance(locale);
calendar.setFirstDayOfWeek(7); //Make Saturdays first day of the week.

//usage
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int weekOfYear = (calendar.get(Calendar.YEAR_WOY) == year)? calendar.get(Calendar.WEEK_OF_YEAR) : 53;
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);


It is important to know Calendar and ULocale are from com.ibm.icu.util.Calendar and com.ibm.icu.util.ULocale. NOT java.util.



If you have any problem in understanding the code, do not hesitate to ask.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 1 at 14:17

























answered Jan 1 at 13:58









hamid ghasemihamid ghasemi

6812624




6812624













  • Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

    – Mohammad Javadi
    Jan 1 at 14:06











  • @MohammadJavadi Code changed to java.

    – hamid ghasemi
    Jan 1 at 14:18



















  • Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

    – Mohammad Javadi
    Jan 1 at 14:06











  • @MohammadJavadi Code changed to java.

    – hamid ghasemi
    Jan 1 at 14:18

















Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

– Mohammad Javadi
Jan 1 at 14:06





Thanks. Unfortunately, I don't know anything about kotlin. Could you please provide Java codes?

– Mohammad Javadi
Jan 1 at 14:06













@MohammadJavadi Code changed to java.

– hamid ghasemi
Jan 1 at 14:18





@MohammadJavadi Code changed to java.

– hamid ghasemi
Jan 1 at 14:18




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995930%2fhow-to-get-week-of-year-and-week-of-month-in-jalali-shamsi-calendar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas