Example usage for java.text DateFormat LONG

List of usage examples for java.text DateFormat LONG

Introduction

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

Prototype

int LONG

To view the source code for java.text DateFormat LONG.

Click Source Link

Document

Constant for long style pattern.

Usage

From source file:com.skplanet.payment.sample.controller.SampleController.java

/**
 * Simply selects the home view to render by returning its name.
 *//*from  w w w .  j  a v  a 2s  .  co  m*/
@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);

    List<HashMap<String, String>> outputs = sqlSession.selectList("userControlMapper.selectSample");
    model.addAttribute("showDB", outputs.toString());

    return "home";
}

From source file:ilearn.orb.controller.ProfilesController.java

@RequestMapping(value = "/profiles")
public ModelAndView profiles(Locale locale, ModelMap modelMap, HttpSession session) {

    ModelAndView model = new ModelAndView();
    model.setViewName("profiles");

    try {//from  w  w  w  . j  a  v a2 s .  c o  m
        Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer())
                .setDateFormat(DateFormat.LONG).create();
        User[] students = null;
        try {
            String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()),
                    session.getAttribute("auth").toString());
            students = gson.fromJson(json, User[].class);
        } catch (NullPointerException e) {
        }
        if (students == null || students.length == 0) {
            students = HardcodedUsers.defaultStudents();
        }
        modelMap.put("students", students);

    } catch (NumberFormatException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return model;

}

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

/**
 * Simply selects the home view to render by returning its name.
 *//*from www  . ja  va  2 s .  co  m*/
@RenderMapping
public String home(Locale locale, Model model) {

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

    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.espian.ticktock.CountdownFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (getArguments() == null)
        throw new IllegalArgumentException("No args supplied for fragment");

    try {/*from  w  w w. j a v  a 2s.  c  o  m*/

        final Date date = DateFormat.getDateInstance(DateFormat.LONG).parse(getArguments().getString("date"));
        mIdAsString = getArguments().getString(BaseColumns._ID);
        mLabelView.setText(mLabel = getArguments().getString("label"));
        mDateView.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date));
        mHelper = new LoadHideHelper(this);

        new Thread(new Runnable() {
            @Override
            public void run() {

                // Requires an ugly fudge because, for some reason, the Days class accesses
                // the disk through random access, which throws errors with StrictMode.
                int days = Days.daysBetween(new DateTime(new Date()), new DateTime(date)).getDays();
                Bundle b = new Bundle();
                b.putString("result", String.valueOf(days + 1));
                Message m = Message.obtain(asyncHandler);
                m.setData(b);
                asyncHandler.sendMessage(m);

            }
        }).start();

    } catch (ParseException e) {
        Toast.makeText(getActivity(), "Malformed date was stored", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }

    //getActivity().getLoaderManager().initLoader(TickTockProvider.LOADER_SINGLE_ITEM, getArguments(), this);

}

From source file:com.liferay.mobile.sample.model.Contact.java

protected DateFormat getDateFormatter() {
    if (_formatter == null) {
        _formatter = DateFormat.getDateInstance(DateFormat.LONG);
    }

    return _formatter;
}

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

/**
 * Simply selects the home view to render by returning its name.
 *///  www.  j a  v a  2  s  .  c om
@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  ww  w.j  av a2  s .  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.
 */// w  w w  . j a v  a 2  s  . c om
@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:DateFormatDemo.java

static public void showDateStyles(Locale currentLocale) {

    Date today = new Date();
    String result;//from  ww  w .  ja  v a2 s .c o m
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getDateInstance(styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:ilearn.orb.controller.AnalysisController.java

@RequestMapping(value = "/analysis")
public ModelAndView textAnalysis(Locale locale, ModelMap modelMap, HttpServletRequest request,
        HttpSession session) {//from ww w .j a  v  a 2  s  . c  om
    try {
        request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
    ModelAndView model = new ModelAndView();
    model.setViewName("analysis");

    try {
        Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer())
                .setDateFormat(DateFormat.LONG).create();
        User[] students = null;
        try {
            String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()),
                    session.getAttribute("auth").toString());
            students = gson.fromJson(json, User[].class);
        } catch (NullPointerException e) {
        }
        if (students == null || students.length == 0) {
            students = HardcodedUsers.defaultStudents();
        }
        modelMap.put("students", students);
        String text = request.getParameter("inputText");
        String profileId = request.getParameter("selectedId");
        if (text != null) {
            text = new String(text.getBytes("8859_1"), "UTF-8");
        } else
            text = "";
        modelMap.put("profileId", profileId);
        modelMap.put("text", text);
        String json;
        if (Integer.parseInt(profileId) > 0)
            json = TextServices.getAnalysisJson(Integer.parseInt(profileId),
                    session.getAttribute("auth").toString(), text);
        else
            json = TextServices
                    .getAnalysisJson(HardcodedUsers.defaultProfileLanguage(Integer.parseInt(profileId)), text);
        AnalysisResults analysisResults = null;
        analysisResults = (new Gson()).fromJson(json, AnalysisResults.class);
        modelMap.put("analysisResults", analysisResults);
        UserProfile pr = retrieveProfile(session, Integer.parseInt(profileId));
        modelMap.put("selectedProfile", pr);
        int maxWordsMatched = 0;
        for (int i = 0; i < pr.getUserProblems().getNumerOfRows(); i++) {
            for (int j = 0; j < pr.getUserProblems().getRowLength(i); j++) {
                if (analysisResults.getUserCounters().getValue(i, j) > maxWordsMatched)
                    maxWordsMatched = analysisResults.getUserCounters().getValue(i, j);
            }
        }
        modelMap.put("maxWordsMatched", maxWordsMatched);

    } catch (NumberFormatException e) {
        //e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return model;

}