Example usage for java.text DateFormat getDateTimeInstance

List of usage examples for java.text DateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateTimeInstance.

Prototype

public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale aLocale) 

Source Link

Document

Gets the date/time formatter with the given formatting styles for the given locale.

Usage

From source file:au.com.redbarn.liferay.portlet.property.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///w  w  w  .ja  v a 2s .  co m
@RenderMapping
public String home(RenderRequest request, Locale locale, Model model) {

    log.info("Welcome home! the client locale is " + locale.toString());

    model.addAttribute(Constants.MESSAGE_PARAM,
            request.getPreferences().getValue(Constants.MESSAGE_PARAM, Constants.DEFAULT_MESSAGE));

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:com.tcloud.bee.key.server.mvc.controller.HomeController.java

/**
 * Simple controller for "/" that returns a Thymeleaf view.
 *//*from  www .ja v  a 2s .c  o  m*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! the client locale is " + locale.toString());

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    logger.trace("Authentication principal: {}", auth.getPrincipal());
    logger.trace("Authentication name: {}", auth.getName());

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);
    // model.addAttribute("echoService", echoService);
    model.addAttribute("someItems", new String[] { "one", "two", "three" });

    return "home";
}

From source file:org.mm.demo.portlet.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *//*from   w ww . j a v  a2 s  .com*/
@RenderMapping
public String home(final Locale locale, final Model model) {
    LOG.info("Welcome home! the client locale is {}", locale.toString());

    final Date date = new Date();
    final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    final String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);
    model.addAttribute("organizationLocalServiceBeanIdentifier", organizationLocalService.getBeanIdentifier());

    return "home";
}

From source file:es.ucm.fdi.dalgs.web.MainController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from w  w  w  . ja va2  s. com
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "/home.htm", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! The client locale is {}.", locale);

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);
    model.addAttribute("class", "User");
    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:ph.fingra.statisticsweb.controller.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from w w  w.j  av  a  2s.c  o  m
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String test(Locale locale, Model model) {
    logger.info("Welcome home! The client locale is {}.", locale);

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    // database & mybatis db mapper test
    model.addAttribute("memberlist", memberService.getList());

    // admin.properties test
    Member admin = new Member();
    admin.setEmail(adminEmail);
    admin.setName(adminName);
    admin.setPassword(adminPassword);
    admin.setRole(MemberRole.ROLE_ADMIN.getValue());
    model.addAttribute("admin", admin);

    return "test";
}

From source file:com.satlabs.testbed.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *//*from   www.j a  va  2s  .com*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! The client locale is {}.", locale);

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:com.lovejoy777sarootool.rootool.adapters.BrowserListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder mViewHolder;
    int num_items = 0;
    final File file = new File(getItem(position));
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault());

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.item_browserlist, parent, false);
        mViewHolder = new ViewHolder(convertView);
        convertView.setTag(mViewHolder);
    } else {/*from  w  w  w  .  ja va 2  s . co  m*/
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    if (Settings.mListAppearance > 0) {
        mViewHolder.dateview.setVisibility(TextView.VISIBLE);
    } else {
        mViewHolder.dateview.setVisibility(TextView.GONE);
    }

    // get icon
    IconPreview.getFileIcon(file, mViewHolder.icon);

    if (file.isFile()) {
        // Shows the size of File
        mViewHolder.bottomView.setText(FileUtils.byteCountToDisplaySize(file.length()));
    } else {
        String[] list = file.list();

        if (list != null)
            num_items = list.length;

        // show the number of files in Folder
        mViewHolder.bottomView.setText(num_items + mResources.getString(R.string.files));
    }

    mViewHolder.topView.setText(file.getName());
    mViewHolder.dateview.setText(df.format(file.lastModified()));

    return convertView;
}

From source file:com.olegchir.fadeok.controller.AppController.java

@RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
public String home(Locale locale, Model model) {

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
    String formattedDate = dateFormat.format(date);
    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:com.simon.server.controller.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *
 * @throws Exception//w ww. j  a  va2 s  .co m
 */
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView home(Locale locale, Model model) throws Exception {

    LOGGER.info(TAG, "Welcome home! The client locale is {}.", locale);
    ModelAndView mav = new ModelAndView();
    mav.setViewName("home");

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    model.addAttribute("peoples", peopleService.getEntityList());

    return mav;
}

From source file:com.dnielfe.manager.adapters.BrowserListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder mViewHolder;
    int num_items = 0;
    final File file = new File(getItem(position));
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault());

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.item_browserlist, parent, false);
        mViewHolder = new ViewHolder(convertView);
        convertView.setTag(mViewHolder);
    } else {/*from   ww  w .  j av  a  2 s  . com*/
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    if (Settings.mListAppearance > 0) {
        mViewHolder.dateview.setVisibility(TextView.VISIBLE);
    } else {
        mViewHolder.dateview.setVisibility(TextView.GONE);
    }

    if (Settings.showthumbnail)
        setIcon(file, mViewHolder.icon);
    else
        loadFromRes(file, mViewHolder.icon);

    if (file.isFile()) {
        // Shows the size of File
        mViewHolder.bottomView.setText(FileUtils.byteCountToDisplaySize(file.length()));
    } else {
        String[] list = file.list();

        if (list != null)
            num_items = list.length;

        // show the number of files in Folder
        mViewHolder.bottomView.setText(num_items + mResources.getString(R.string.files));
    }

    mViewHolder.topView.setText(file.getName());
    mViewHolder.dateview.setText(df.format(file.lastModified()));

    return convertView;
}