0

ZK Calender12 Hours Format [closed]

asked 2015-02-26 14:53:30 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

updated 2015-02-28 10:15:36 +0800

How to show ZK Calender in 12 Hours Format ?

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by Senthilchettyin
close date 2015-03-02 07:11:24

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-02-28 10:08:05 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Senthilchettyin,

You could refer to the following url which describes how to format dates:

http://books.zkoss.org/wiki/ZK%20Calendar%20Essentials/Working%20with%20ZK%20Calendar/Displaying%20ZK%20Calendar%20Event%20Data/Managing%20Event%20Data/Date%20Formatting

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-02-28 10:17:18 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Hello

Thank you. But that interface useful when we want to change he caption. I dont think so, we can change the date format shown on the left hand side of the calender itself.

link publish delete flag offensive edit
0

answered 2015-03-02 07:11:11 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

I am sorry for the previous answers. Yes it works, i am able to change to 12 Hours Format as shown here

calendarCtrl.setDateFormatter(new MyCalenderDateFormat());

    package com.product.webapp.appt;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import org.zkoss.calendar.api.DateFormatter;

public class MyCalenderDateFormat implements DateFormatter {

    private String _dayFormat = "EEE MM/d";
    private String _weekFormat = "EEE";
    private String _timeFormat = "hh:mm a";
    private String _ppFormat = "EEE, MMM/d";
    private SimpleDateFormat _df, _wf, _tf, _pf;

    public String getCaptionByDate(Date date, Locale locale, TimeZone timezone) {
        if (_df == null) {
            _df = new SimpleDateFormat(_dayFormat, locale);
        }
        _df.setTimeZone(timezone);

        return _df.format(date);
    }

    public String getCaptionByDateOfMonth(Date date, Locale locale,
            TimeZone timezone) {
        Calendar cal = Calendar.getInstance(timezone, locale);
        cal.setTime(date);
        if (cal.get(Calendar.DAY_OF_MONTH) == 1) {
            SimpleDateFormat sd = new SimpleDateFormat("MMM d", locale);
            sd.setTimeZone(timezone);
            return sd.format(date);
        }
        return Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    }

    public String getCaptionByDayOfWeek(Date date, Locale locale,
            TimeZone timezone) {
        if (_wf == null) {
            _wf = new SimpleDateFormat(_weekFormat, locale);
        }
        _wf.setTimeZone(timezone);
        return _wf.format(date);
    }

    public String getCaptionByTimeOfDay(Date date, Locale locale,
            TimeZone timezone) {
        if (_tf == null) {
            _tf = new SimpleDateFormat(_timeFormat, locale);
        }
        _tf.setTimeZone(timezone);

        return _tf.format(date);
    }

    public String getCaptionByPopup(Date date, Locale locale, TimeZone timezone) {
        if (_pf == null) {
            _pf = new SimpleDateFormat(_ppFormat, locale);
        }
        _pf.setTimeZone(timezone);

        return _pf.format(date);
    }

    public String getCaptionByWeekOfYear(Date date, Locale locale,
            TimeZone timezone) {
        Calendar cal = Calendar.getInstance(timezone, locale);
        cal.setTime(date);
        return String.valueOf(cal.get(Calendar.WEEK_OF_YEAR));
    }
}
link publish delete flag offensive edit

Question tools

Follow
2 followers

RSS

Stats

Asked: 2015-02-26 14:53:30 +0800

Seen: 20 times

Last updated: Mar 02 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More