Postingan lainnya
Ask Java, Menampilkan data perminggu, perbulan dan pertahun ?
Selamat pagi master-master
saya agak kesulitan dalam menampilkan data berdasarkan minggu ini, bulan ini dan tahun ini, kira-kira query untuk menampilkan data tersebut bagaimana yah ?
mohon bantuannya
0
4 Jawaban:
Jawaban Terpilih
Coba ini gan, sudah berdasarkan perminggu, perbulan, dan pertahun.
tinggal ditambahin logic untuk get data nya di date tersebut.
import java.util.Calendar;
import java.util.Date;
public class HelloWorld
{
public static void main(String []args)
{
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());//Set specific Date if you want to
System.out.println("Date of Week:");
for(int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
cal.set(Calendar.DAY_OF_WEEK, i);
System.out.println(cal.getTime());//Returns Date
}
System.out.println();
System.out.println("Date of Month: ");
cal.setTime(new Date());//Set specific Date if you want to
int maxDayMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
for(int i = 1; i <= maxDayMonth; i++) {
cal.set(Calendar.DAY_OF_MONTH, i);
System.out.println(cal.getTime());//Returns Date
}
System.out.println();
System.out.println("Date of Year: ");
cal.setTime(new Date());//Set specific Date if you want to
int maxDayYear = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
for(int i = 1; i <= maxDayYear; i++) {
cal.set(Calendar.DAY_OF_YEAR, i);
System.out.println(cal.getTime());//Returns Date
}
}
}
Hasilnya:
Date of Week:
Sun Apr 22 04:32:18 UTC 2018
Mon Apr 23 04:32:18 UTC 2018
Tue Apr 24 04:32:18 UTC 2018
Wed Apr 25 04:32:18 UTC 2018
Thu Apr 26 04:32:18 UTC 2018
Fri Apr 27 04:32:18 UTC 2018
Sat Apr 28 04:32:18 UTC 2018
Date of Month:
Sun Apr 01 04:32:18 UTC 2018
Mon Apr 02 04:32:18 UTC 2018
Tue Apr 03 04:32:18 UTC 2018
Wed Apr 04 04:32:18 UTC 2018
Thu Apr 05 04:32:18 UTC 2018
Fri Apr 06 04:32:18 UTC 2018
Sat Apr 07 04:32:18 UTC 2018
Sun Apr 08 04:32:18 UTC 2018
Mon Apr 09 04:32:18 UTC 2018
Tue Apr 10 04:32:18 UTC 2018
Wed Apr 11 04:32:18 UTC 2018
Thu Apr 12 04:32:18 UTC 2018
Fri Apr 13 04:32:18 UTC 2018
Sat Apr 14 04:32:18 UTC 2018
Sun Apr 15 04:32:18 UTC 2018
Mon Apr 16 04:32:18 UTC 2018
Tue Apr 17 04:32:18 UTC 2018
Wed Apr 18 04:32:18 UTC 2018
Thu Apr 19 04:32:18 UTC 2018
Fri Apr 20 04:32:18 UTC 2018
Sat Apr 21 04:32:18 UTC 2018
Sun Apr 22 04:32:18 UTC 2018
Mon Apr 23 04:32:18 UTC 2018
Tue Apr 24 04:32:18 UTC 2018
Wed Apr 25 04:32:18 UTC 2018
Thu Apr 26 04:32:18 UTC 2018
Fri Apr 27 04:32:18 UTC 2018
Sat Apr 28 04:32:18 UTC 2018
Sun Apr 29 04:32:18 UTC 2018
Mon Apr 30 04:32:18 UTC 2018
Date of Year:
Mon Jan 01 04:32:18 UTC 2018
Tue Jan 02 04:32:18 UTC 2018
Wed Jan 03 04:32:18 UTC 2018
Thu Jan 04 04:32:18 UTC 2018
Fri Jan 05 04:32:18 UTC 2018
Sat Jan 06 04:32:18 UTC 2018
Sun Jan 07 04:32:18 UTC 2018
Mon Jan 08 04:32:18 UTC 2018
Tue Jan 09 04:32:18 UTC 2018
Wed Jan 10 04:32:18 UTC 2018
Thu Jan 11 04:32:18 UTC 2018
Fri Jan 12 04:32:18 UTC 2018
Sat Jan 13 04:32:18 UTC 2018
Sun Jan 14 04:32:18 UTC 2018
Mon Jan 15 04:32:18 UTC 2018
Tue Jan 16 04:32:18 UTC 2018
Wed Jan 17 04:32:18 UTC 2018
Thu Jan 18 04:32:18 UTC 2018
Fri Jan 19 04:32:18 UTC 2018
Sat Jan 20 04:32:18 UTC 2018
Sun Jan 21 04:32:18 UTC 2018
Mon Jan 22 04:32:18 UTC 2018
Tue Jan 23 04:32:18 UTC 2018
Wed Jan 24 04:32:18 UTC 2018
Thu Jan 25 04:32:18 UTC 2018
Fri Jan 26 04:32:18 UTC 2018
Sat Jan 27 04:32:18 UTC 2018
Sun Jan 28 04:32:18 UTC 2018
Mon Jan 29 04:32:18 UTC 2018
Tue Jan 30 04:32:18 UTC 2018
Wed Jan 31 04:32:18 UTC 2018
Thu Feb 01 04:32:18 UTC 2018
Fri Feb 02 04:32:18 UTC 2018
Sat Feb 03 04:32:18 UTC 2018
Sun Feb 04 04:32:18 UTC 2018
Mon Feb 05 04:32:18 UTC 2018
Tue Feb 06 04:32:18 UTC 2018
Wed Feb 07 04:32:18 UTC 2018
Thu Feb 08 04:32:18 UTC 2018
Fri Feb 09 04:32:18 UTC 2018
Sat Feb 10 04:32:18 UTC 2018
Sun Feb 11 04:32:18 UTC 2018
Mon Feb 12 04:32:18 UTC 2018
Tue Feb 13 04:32:18 UTC 2018
Wed Feb 14 04:32:18 UTC 2018
Thu Feb 15 04:32:18 UTC 2018
Fri Feb 16 04:32:18 UTC 2018
Sat Feb 17 04:32:18 UTC 2018
Sun Feb 18 04:32:18 UTC 2018
Mon Feb 19 04:32:18 UTC 2018
Tue Feb 20 04:32:18 UTC 2018
Wed Feb 21 04:32:18 UTC 2018
Thu Feb 22 04:32:18 UTC 2018
Fri Feb 23 04:32:18 UTC 2018
Sat Feb 24 04:32:18 UTC 2018
Sun Feb 25 04:32:18 UTC 2018
Mon Feb 26 04:32:18 UTC 2018
Tue Feb 27 04:32:18 UTC 2018
Wed Feb 28 04:32:18 UTC 2018
Thu Mar 01 04:32:18 UTC 2018
Fri Mar 02 04:32:18 UTC 2018
Sat Mar 03 04:32:18 UTC 2018
Sun Mar 04 04:32:18 UTC 2018
Mon Mar 05 04:32:18 UTC 2018
Tue Mar 06 04:32:18 UTC 2018
Wed Mar 07 04:32:18 UTC 2018
Thu Mar 08 04:32:18 UTC 2018
Fri Mar 09 04:32:18 UTC 2018
Sat Mar 10 04:32:18 UTC 2018
Sun Mar 11 04:32:18 UTC 2018
Mon Mar 12 04:32:18 UTC 2018
Tue Mar 13 04:32:18 UTC 2018
Wed Mar 14 04:32:18 UTC 2018
Thu Mar 15 04:32:18 UTC 2018
Fri Mar 16 04:32:18 UTC 2018
Sat Mar 17 04:32:18 UTC 2018
Sun Mar 18 04:32:18 UTC 2018
Mon Mar 19 04:32:18 UTC 2018
Tue Mar 20 04:32:18 UTC 2018
Wed Mar 21 04:32:18 UTC 2018
Thu Mar 22 04:32:18 UTC 2018
Fri Mar 23 04:32:18 UTC 2018
Sat Mar 24 04:32:18 UTC 2018
Sun Mar 25 04:32:18 UTC 2018
Mon Mar 26 04:32:18 UTC 2018
Tue Mar 27 04:32:18 UTC 2018
Wed Mar 28 04:32:18 UTC 2018
Thu Mar 29 04:32:18 UTC 2018
Fri Mar 30 04:32:18 UTC 2018
Sat Mar 31 04:32:18 UTC 2018
Sun Apr 01 04:32:18 UTC 2018
Mon Apr 02 04:32:18 UTC 2018
Tue Apr 03 04:32:18 UTC 2018
Wed Apr 04 04:32:18 UTC 2018
Thu Apr 05 04:32:18 UTC 2018
Fri Apr 06 04:32:18 UTC 2018
Sat Apr 07 04:32:18 UTC 2018
Sun Apr 08 04:32:18 UTC 2018
Mon Apr 09 04:32:18 UTC 2018
Tue Apr 10 04:32:18 UTC 2018
Wed Apr 11 04:32:18 UTC 2018
Thu Apr 12 04:32:18 UTC 2018
Fri Apr 13 04:32:18 UTC 2018
Sat Apr 14 04:32:18 UTC 2018
Sun Apr 15 04:32:18 UTC 2018
Mon Apr 16 04:32:18 UTC 2018
Tue Apr 17 04:32:18 UTC 2018
Wed Apr 18 04:32:18 UTC 2018
Thu Apr 19 04:32:18 UTC 2018
Fri Apr 20 04:32:18 UTC 2018
Sat Apr 21 04:32:18 UTC 2018
Sun Apr 22 04:32:18 UTC 2018
Mon Apr 23 04:32:18 UTC 2018
Tue Apr 24 04:32:18 UTC 2018
Wed Apr 25 04:32:18 UTC 2018
Thu Apr 26 04:32:18 UTC 2018
Fri Apr 27 04:32:18 UTC 2018
Sat Apr 28 04:32:18 UTC 2018
Sun Apr 29 04:32:18 UTC 2018
Mon Apr 30 04:32:18 UTC 2018
Tue May 01 04:32:18 UTC 2018
Wed May 02 04:32:18 UTC 2018
Thu May 03 04:32:18 UTC 2018
Fri May 04 04:32:18 UTC 2018
Sat May 05 04:32:18 UTC 2018
Sun May 06 04:32:18 UTC 2018
Mon May 07 04:32:18 UTC 2018
Tue May 08 04:32:18 UTC 2018
Wed May 09 04:32:18 UTC 2018
Thu May 10 04:32:18 UTC 2018
Fri May 11 04:32:18 UTC 2018
Sat May 12 04:32:18 UTC 2018
Sun May 13 04:32:18 UTC 2018
Mon May 14 04:32:18 UTC 2018
Tue May 15 04:32:18 UTC 2018
Wed May 16 04:32:18 UTC 2018
Thu May 17 04:32:18 UTC 2018
Fri May 18 04:32:18 UTC 2018
Sat May 19 04:32:18 UTC 2018
Sun May 20 04:32:18 UTC 2018
Mon May 21 04:32:18 UTC 2018
Tue May 22 04:32:18 UTC 2018
Wed May 23 04:32:18 UTC 2018
Thu May 24 04:32:18 UTC 2018
Fri May 25 04:32:18 UTC 2018
Sat May 26 04:32:18 UTC 2018
Sun May 27 04:32:18 UTC 2018
Mon May 28 04:32:18 UTC 2018
Tue May 29 04:32:18 UTC 2018
Wed May 30 04:32:18 UTC 2018
Thu May 31 04:32:18 UTC 2018
Fri Jun 01 04:32:18 UTC 2018
Sat Jun 02 04:32:18 UTC 2018
Sun Jun 03 04:32:18 UTC 2018
Mon Jun 04 04:32:18 UTC 2018
Tue Jun 05 04:32:18 UTC 2018
Wed Jun 06 04:32:18 UTC 2018
Thu Jun 07 04:32:18 UTC 2018
Fri Jun 08 04:32:18 UTC 2018
Sat Jun 09 04:32:18 UTC 2018
Sun Jun 10 04:32:18 UTC 2018
Mon Jun 11 04:32:18 UTC 2018
Tue Jun 12 04:32:18 UTC 2018
Wed Jun 13 04:32:18 UTC 2018
Thu Jun 14 04:32:18 UTC 2018
Fri Jun 15 04:32:18 UTC 2018
Sat Jun 16 04:32:18 UTC 2018
Sun Jun 17 04:32:18 UTC 2018
Mon Jun 18 04:32:18 UTC 2018
Tue Jun 19 04:32:18 UTC 2018
Wed Jun 20 04:32:18 UTC 2018
Thu Jun 21 04:32:18 UTC 2018
Fri Jun 22 04:32:18 UTC 2018
Sat Jun 23 04:32:18 UTC 2018
Sun Jun 24 04:32:18 UTC 2018
Mon Jun 25 04:32:18 UTC 2018
Tue Jun 26 04:32:18 UTC 2018
Wed Jun 27 04:32:18 UTC 2018
Thu Jun 28 04:32:18 UTC 2018
Fri Jun 29 04:32:18 UTC 2018
Sat Jun 30 04:32:18 UTC 2018
Sun Jul 01 04:32:18 UTC 2018
Mon Jul 02 04:32:18 UTC 2018
Tue Jul 03 04:32:18 UTC 2018
Wed Jul 04 04:32:18 UTC 2018
Thu Jul 05 04:32:18 UTC 2018
Fri Jul 06 04:32:18 UTC 2018
Sat Jul 07 04:32:18 UTC 2018
Sun Jul 08 04:32:18 UTC 2018
Mon Jul 09 04:32:18 UTC 2018
Tue Jul 10 04:32:18 UTC 2018
Wed Jul 11 04:32:18 UTC 2018
Thu Jul 12 04:32:18 UTC 2018
Fri Jul 13 04:32:18 UTC 2018
Sat Jul 14 04:32:18 UTC 2018
Sun Jul 15 04:32:18 UTC 2018
Mon Jul 16 04:32:18 UTC 2018
Tue Jul 17 04:32:18 UTC 2018
Wed Jul 18 04:32:18 UTC 2018
Thu Jul 19 04:32:18 UTC 2018
Fri Jul 20 04:32:18 UTC 2018
Sat Jul 21 04:32:18 UTC 2018
Sun Jul 22 04:32:18 UTC 2018
Mon Jul 23 04:32:18 UTC 2018
Tue Jul 24 04:32:18 UTC 2018
Wed Jul 25 04:32:18 UTC 2018
Thu Jul 26 04:32:18 UTC 2018
Fri Jul 27 04:32:18 UTC 2018
Sat Jul 28 04:32:18 UTC 2018
Sun Jul 29 04:32:18 UTC 2018
Mon Jul 30 04:32:18 UTC 2018
Tue Jul 31 04:32:18 UTC 2018
Wed Aug 01 04:32:18 UTC 2018
Thu Aug 02 04:32:18 UTC 2018
Fri Aug 03 04:32:18 UTC 2018
Sat Aug 04 04:32:18 UTC 2018
Sun Aug 05 04:32:18 UTC 2018
Mon Aug 06 04:32:18 UTC 2018
Tue Aug 07 04:32:18 UTC 2018
Wed Aug 08 04:32:18 UTC 2018
Thu Aug 09 04:32:18 UTC 2018
Fri Aug 10 04:32:18 UTC 2018
Sat Aug 11 04:32:18 UTC 2018
Sun Aug 12 04:32:18 UTC 2018
Mon Aug 13 04:32:18 UTC 2018
Tue Aug 14 04:32:18 UTC 2018
Wed Aug 15 04:32:18 UTC 2018
Thu Aug 16 04:32:18 UTC 2018
Fri Aug 17 04:32:18 UTC 2018
Sat Aug 18 04:32:18 UTC 2018
Sun Aug 19 04:32:18 UTC 2018
Mon Aug 20 04:32:18 UTC 2018
Tue Aug 21 04:32:18 UTC 2018
Wed Aug 22 04:32:18 UTC 2018
Thu Aug 23 04:32:18 UTC 2018
Fri Aug 24 04:32:18 UTC 2018
Sat Aug 25 04:32:18 UTC 2018
Sun Aug 26 04:32:18 UTC 2018
Mon Aug 27 04:32:18 UTC 2018
Tue Aug 28 04:32:18 UTC 2018
Wed Aug 29 04:32:18 UTC 2018
Thu Aug 30 04:32:18 UTC 2018
Fri Aug 31 04:32:18 UTC 2018
Sat Sep 01 04:32:18 UTC 2018
Sun Sep 02 04:32:18 UTC 2018
Mon Sep 03 04:32:18 UTC 2018
Tue Sep 04 04:32:18 UTC 2018
Wed Sep 05 04:32:18 UTC 2018
Thu Sep 06 04:32:18 UTC 2018
Fri Sep 07 04:32:18 UTC 2018
Sat Sep 08 04:32:18 UTC 2018
Sun Sep 09 04:32:18 UTC 2018
Mon Sep 10 04:32:18 UTC 2018
Tue Sep 11 04:32:18 UTC 2018
Wed Sep 12 04:32:18 UTC 2018
Thu Sep 13 04:32:18 UTC 2018
Fri Sep 14 04:32:18 UTC 2018
Sat Sep 15 04:32:18 UTC 2018
Sun Sep 16 04:32:18 UTC 2018
Mon Sep 17 04:32:18 UTC 2018
Tue Sep 18 04:32:18 UTC 2018
Wed Sep 19 04:32:18 UTC 2018
Thu Sep 20 04:32:18 UTC 2018
Fri Sep 21 04:32:18 UTC 2018
Sat Sep 22 04:32:18 UTC 2018
Sun Sep 23 04:32:18 UTC 2018
Mon Sep 24 04:32:18 UTC 2018
Tue Sep 25 04:32:18 UTC 2018
Wed Sep 26 04:32:18 UTC 2018
Thu Sep 27 04:32:18 UTC 2018
Fri Sep 28 04:32:18 UTC 2018
Sat Sep 29 04:32:18 UTC 2018
Sun Sep 30 04:32:18 UTC 2018
Mon Oct 01 04:32:18 UTC 2018
Tue Oct 02 04:32:18 UTC 2018
Wed Oct 03 04:32:18 UTC 2018
Thu Oct 04 04:32:18 UTC 2018
Fri Oct 05 04:32:18 UTC 2018
Sat Oct 06 04:32:18 UTC 2018
Sun Oct 07 04:32:18 UTC 2018
Mon Oct 08 04:32:18 UTC 2018
Tue Oct 09 04:32:18 UTC 2018
Wed Oct 10 04:32:18 UTC 2018
Thu Oct 11 04:32:18 UTC 2018
Fri Oct 12 04:32:18 UTC 2018
Sat Oct 13 04:32:18 UTC 2018
Sun Oct 14 04:32:18 UTC 2018
Mon Oct 15 04:32:18 UTC 2018
Tue Oct 16 04:32:18 UTC 2018
Wed Oct 17 04:32:18 UTC 2018
Thu Oct 18 04:32:18 UTC 2018
Fri Oct 19 04:32:18 UTC 2018
Sat Oct 20 04:32:18 UTC 2018
Sun Oct 21 04:32:18 UTC 2018
Mon Oct 22 04:32:18 UTC 2018
Tue Oct 23 04:32:18 UTC 2018
Wed Oct 24 04:32:18 UTC 2018
Thu Oct 25 04:32:18 UTC 2018
Fri Oct 26 04:32:18 UTC 2018
Sat Oct 27 04:32:18 UTC 2018
Sun Oct 28 04:32:18 UTC 2018
Mon Oct 29 04:32:18 UTC 2018
Tue Oct 30 04:32:18 UTC 2018
Wed Oct 31 04:32:18 UTC 2018
Thu Nov 01 04:32:18 UTC 2018
Fri Nov 02 04:32:18 UTC 2018
Sat Nov 03 04:32:18 UTC 2018
Sun Nov 04 04:32:18 UTC 2018
Mon Nov 05 04:32:18 UTC 2018
Tue Nov 06 04:32:18 UTC 2018
Wed Nov 07 04:32:18 UTC 2018
Thu Nov 08 04:32:18 UTC 2018
Fri Nov 09 04:32:18 UTC 2018
Sat Nov 10 04:32:18 UTC 2018
Sun Nov 11 04:32:18 UTC 2018
Mon Nov 12 04:32:18 UTC 2018
Tue Nov 13 04:32:18 UTC 2018
Wed Nov 14 04:32:18 UTC 2018
Thu Nov 15 04:32:18 UTC 2018
Fri Nov 16 04:32:18 UTC 2018
Sat Nov 17 04:32:18 UTC 2018
Sun Nov 18 04:32:18 UTC 2018
Mon Nov 19 04:32:18 UTC 2018
Tue Nov 20 04:32:18 UTC 2018
Wed Nov 21 04:32:18 UTC 2018
Thu Nov 22 04:32:18 UTC 2018
Fri Nov 23 04:32:18 UTC 2018
Sat Nov 24 04:32:18 UTC 2018
Sun Nov 25 04:32:18 UTC 2018
Mon Nov 26 04:32:18 UTC 2018
Tue Nov 27 04:32:18 UTC 2018
Wed Nov 28 04:32:18 UTC 2018
Thu Nov 29 04:32:18 UTC 2018
Fri Nov 30 04:32:18 UTC 2018
Sat Dec 01 04:32:18 UTC 2018
Sun Dec 02 04:32:18 UTC 2018
Mon Dec 03 04:32:18 UTC 2018
Tue Dec 04 04:32:18 UTC 2018
Wed Dec 05 04:32:18 UTC 2018
Thu Dec 06 04:32:18 UTC 2018
Fri Dec 07 04:32:18 UTC 2018
Sat Dec 08 04:32:18 UTC 2018
Sun Dec 09 04:32:18 UTC 2018
Mon Dec 10 04:32:18 UTC 2018
Tue Dec 11 04:32:18 UTC 2018
Wed Dec 12 04:32:18 UTC 2018
Thu Dec 13 04:32:18 UTC 2018
Fri Dec 14 04:32:18 UTC 2018
Sat Dec 15 04:32:18 UTC 2018
Sun Dec 16 04:32:18 UTC 2018
Mon Dec 17 04:32:18 UTC 2018
Tue Dec 18 04:32:18 UTC 2018
Wed Dec 19 04:32:18 UTC 2018
Thu Dec 20 04:32:18 UTC 2018
Fri Dec 21 04:32:18 UTC 2018
Sat Dec 22 04:32:18 UTC 2018
Sun Dec 23 04:32:18 UTC 2018
Mon Dec 24 04:32:18 UTC 2018
Tue Dec 25 04:32:18 UTC 2018
Wed Dec 26 04:32:18 UTC 2018
Thu Dec 27 04:32:18 UTC 2018
Fri Dec 28 04:32:18 UTC 2018
Sat Dec 29 04:32:18 UTC 2018
Sun Dec 30 04:32:18 UTC 2018
Mon Dec 31 04:32:18 UTC 2018
0
terima kasih banyak bang, sangat membantu
0