How to get week of year and week of month in Jalali (Shamsi) calendar
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
add a comment |
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
What is yourJalaliCalender
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
add a comment |
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
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
java
edited Jan 1 at 13:53
Mohammad Javadi
asked Jan 1 at 13:41
Mohammad JavadiMohammad Javadi
82
82
What is yourJalaliCalender
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
add a comment |
What is yourJalaliCalender
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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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